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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 chrome.app.runtime.onLaunched.addListener(function() { 5 function launchFileManager(launchData) {
6 chrome.app.window.create('main.html', { 6 var options = {
7 height: 800, 7 defaultWidth: Math.round(window.screen.availWidth * 0.8),
8 width: 1000 8 defaultHeight: Math.round(window.screen.availHeight * 0.8)
9 };
10
11 chrome.app.window.create('main.html', options, function(newWindow) {
12 newWindow.contentWindow.launchData = launchData;
9 }); 13 });
14 }
15
16 chrome.app.runtime.onLaunched.addListener(launchFileManager);
17
18 chrome.fileBrowserHandler.onExecute.addListener(function(id, details) {
19 var entry = details.entries[0];
20 var url = entry.toURL();
21 switch (id) {
22 case 'play':
23 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
24 break;
25
26 case 'watch':
27 launchVideoPlayer(url);
28 break;
29
30 default:
31 // Every other action opens the main Files app window.
32 var launchData = {};
33 launchData.action = id;
34 launchData.defaultPath = entry.fullPath;
35 launchFileManager(launchData);
36 break;
37 }
10 }); 38 });
11 39
12 /** 40 /**
13 * Wrapper for a singleton app window. 41 * Wrapper for a singleton app window.
14 * @constructor 42 * @constructor
15 */ 43 */
16 function SingletonWindow() { 44 function SingletonWindow() {
17 this.window_ = null; 45 this.window_ = null;
18 this.creating_ = false; 46 this.creating_ = false;
19 } 47 }
(...skipping 11 matching lines...) Expand all
31 if (this.window_ && !this.window_.contentWindow.closed) { 59 if (this.window_ && !this.window_.contentWindow.closed) {
32 this.window_.focus(); 60 this.window_.focus();
33 this.window_.contentWindow.reload(launchData); 61 this.window_.contentWindow.reload(launchData);
34 return; 62 return;
35 } 63 }
36 64
37 this.launchData_ = launchData; 65 this.launchData_ = launchData;
38 if (this.creating_) 66 if (this.creating_)
39 return; // The window is being created, will use the updated launch data. 67 return; // The window is being created, will use the updated launch data.
40 68
69 options.id = url;
41 this.creating_ = true; 70 this.creating_ = true;
42 chrome.app.window.create(url, options, function(newWindow) { 71 chrome.app.window.create(url, options, function(newWindow) {
43 this.window_ = newWindow; 72 this.window_ = newWindow;
44 this.window_.contentWindow.launchData = this.launchData_; 73 this.window_.contentWindow.launchData = this.launchData_;
45 this.creating_ = false; 74 this.creating_ = false;
46 this.window_.onClosed.addListener(function() { 75 this.window_.onClosed.addListener(function() {
47 this.window_.contentWindow_.unload(); 76 this.window_.contentWindow_.unload();
48 }.bind(this)); 77 }.bind(this));
49 }.bind(this)); 78 }.bind(this));
50 }; 79 };
51 80
52 var audioPlayer = new SingletonWindow(); 81 var audioPlayer = new SingletonWindow();
53 82
54 /** 83 /**
55 * Launch the audio player or load the playlist into the existing player. 84 * Launch the audio player or load the playlist into the existing player.
56 * 85 *
57 * @param {Object} playlist Playlist. 86 * @param {Object} playlist Playlist.
58 */ 87 */
59 function launchAudioPlayer(playlist) { 88 function launchAudioPlayer(playlist) {
60 var WIDTH = 280; 89 var WIDTH = 280;
61 var MIN_HEIGHT = 35 + 58; 90 var MIN_HEIGHT = 35 + 58;
62 var MAX_HEIGHT = 35 + 58 * 3; 91 var MAX_HEIGHT = 35 + 58 * 3;
63 var BOTTOM = 80; 92 var BOTTOM = 80;
64 var RIGHT = 20; 93 var RIGHT = 20;
65 94
66 var param = { 95 var options = {
67 id: 'audio',
68 defaultLeft: (window.screen.availWidth - WIDTH - RIGHT), 96 defaultLeft: (window.screen.availWidth - WIDTH - RIGHT),
69 defaultTop: (window.screen.availHeight - MIN_HEIGHT - BOTTOM), 97 defaultTop: (window.screen.availHeight - MIN_HEIGHT - BOTTOM),
70 minHeight: MIN_HEIGHT, 98 minHeight: MIN_HEIGHT,
71 maxHeight: MAX_HEIGHT, 99 maxHeight: MAX_HEIGHT,
72 height: MIN_HEIGHT, 100 height: MIN_HEIGHT,
73 minWidth: WIDTH, 101 minWidth: WIDTH,
74 maxWidth: WIDTH, 102 maxWidth: WIDTH,
75 width: WIDTH 103 width: WIDTH
76 }; 104 };
77 105
78 audioPlayer.open('mediaplayer.html', param, playlist); 106 audioPlayer.open('mediaplayer.html', options, playlist);
79 } 107 }
80 108
81 var videoPlayer = new SingletonWindow(); 109 var videoPlayer = new SingletonWindow();
82 110
83 /** 111 /**
84 * Launch video player. 112 * Launch video player.
85 * @param {string} url Video url. 113 * @param {string} url Video url.
86 */ 114 */
87 function launchVideoPlayer(url) { 115 function launchVideoPlayer(url) {
88 var param = { 116 var options = {
89 id: 'video',
90 hidden: true // Will be shown when the video loads. 117 hidden: true // Will be shown when the video loads.
91 }; 118 };
92 119
93 videoPlayer.open('video_player.html', param, {url: url}); 120 videoPlayer.open('video_player.html', options, {url: url});
94 } 121 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698