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

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: 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..f8841952cc394ab18bd7b8c1b6ea5713296e35cd 100644
--- a/chrome/browser/resources/file_manager/js/background.js
+++ b/chrome/browser/resources/file_manager/js/background.js
@@ -2,11 +2,39 @@
// 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 entry = details.entries[0];
+ var url = entry.toURL();
+ switch (id) {
+ case 'play':
+ launchAudioPlayer({items: [url], position: 0});
dgozman 2012/11/08 13:49:28 Why don't you pass multiple urls here?
Vladislav Kaznacheev 2012/11/08 14:00:18 Only because I know that we never pass more than o
+ break;
+
+ case 'watch':
+ launchVideoPlayer(url);
+ break;
+
+ default:
+ // Every other action opens the main Files app window.
+ var launchData = {};
+ launchData.action = id;
+ launchData.defaultPath = entry.fullPath;
+ launchFileManager(launchData);
+ break;
+ }
});
/**
@@ -38,6 +66,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 +92,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 +103,7 @@ function launchAudioPlayer(playlist) {
width: WIDTH
};
- audioPlayer.open('mediaplayer.html', param, playlist);
+ audioPlayer.open('mediaplayer.html', options, playlist);
}
var videoPlayer = new SingletonWindow();
@@ -85,10 +113,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});
}

Powered by Google App Engine
This is Rietveld 408576698