OLD | NEW |
---|---|
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 'use strict'; | 5 'use strict'; |
6 | 6 |
7 /** | 7 /** |
8 * This object encapsulates everything related to tasks execution. | 8 * This object encapsulates everything related to tasks execution. |
9 * | 9 * |
10 * TODO(hirono): Pass each component instead of the entire FileManager. | 10 * TODO(hirono): Pass each component instead of the entire FileManager. |
(...skipping 28 matching lines...) Expand all Loading... | |
39 /** | 39 /** |
40 * Base URL of apps list in the Chrome Web Store. This constant is used in | 40 * Base URL of apps list in the Chrome Web Store. This constant is used in |
41 * FileTasks.createWebStoreLink(). | 41 * FileTasks.createWebStoreLink(). |
42 * | 42 * |
43 * @const | 43 * @const |
44 * @type {string} | 44 * @type {string} |
45 */ | 45 */ |
46 FileTasks.WEB_STORE_HANDLER_BASE_URL = | 46 FileTasks.WEB_STORE_HANDLER_BASE_URL = |
47 'https://chrome.google.com/webstore/category/collection/file_handlers'; | 47 'https://chrome.google.com/webstore/category/collection/file_handlers'; |
48 | 48 |
49 | |
50 /** | |
51 * The app ID of the video player app. | |
52 * @const | |
53 * @type {string} | |
54 */ | |
55 FileTasks.VIDEO_PLAYER_ID = 'jcgeabjmjgoblfofpppfkcoakmfobdko'; | |
56 | |
49 /** | 57 /** |
50 * Returns URL of the Chrome Web Store which show apps supporting the given | 58 * Returns URL of the Chrome Web Store which show apps supporting the given |
51 * file-extension and mime-type. | 59 * file-extension and mime-type. |
52 * | 60 * |
53 * @param {string} extension Extension of the file (with the first dot). | 61 * @param {string} extension Extension of the file (with the first dot). |
54 * @param {string} mimeType Mime type of the file. | 62 * @param {string} mimeType Mime type of the file. |
55 * @return {string} URL | 63 * @return {string} URL |
56 */ | 64 */ |
57 FileTasks.createWebStoreLink = function(extension, mimeType) { | 65 FileTasks.createWebStoreLink = function(extension, mimeType) { |
58 if (!extension) | 66 if (!extension) |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
182 FileTasks.isInternalTask_ = function(taskId) { | 190 FileTasks.isInternalTask_ = function(taskId) { |
183 var taskParts = taskId.split('|'); | 191 var taskParts = taskId.split('|'); |
184 var appId = taskParts[0]; | 192 var appId = taskParts[0]; |
185 var taskType = taskParts[1]; | 193 var taskType = taskParts[1]; |
186 var actionId = taskParts[2]; | 194 var actionId = taskParts[2]; |
187 // The action IDs here should match ones used in executeInternalTask_(). | 195 // The action IDs here should match ones used in executeInternalTask_(). |
188 return (appId === chrome.runtime.id && | 196 return (appId === chrome.runtime.id && |
189 taskType === 'file' && | 197 taskType === 'file' && |
190 (actionId === 'play' || | 198 (actionId === 'play' || |
191 actionId === 'mount-archive' || | 199 actionId === 'mount-archive' || |
192 actionId === 'gallery')); | 200 actionId === 'gallery' || |
201 actionId === 'gallery-video')); | |
193 }; | 202 }; |
194 | 203 |
195 /** | 204 /** |
196 * Processes internal tasks. | 205 * Processes internal tasks. |
197 * | 206 * |
198 * @param {Array.<Object>} tasks The tasks. | 207 * @param {Array.<Object>} tasks The tasks. |
199 * @private | 208 * @private |
200 */ | 209 */ |
201 FileTasks.prototype.processTasks_ = function(tasks) { | 210 FileTasks.prototype.processTasks_ = function(tasks) { |
202 this.tasks_ = []; | 211 this.tasks_ = []; |
203 var id = chrome.runtime.id; | 212 var id = chrome.runtime.id; |
204 var isOnDrive = false; | 213 var isOnDrive = false; |
205 var fm = this.fileManager_; | 214 var fm = this.fileManager_; |
215 var isMultiple = (this.entries_.length > 1); | |
206 for (var index = 0; index < this.entries_.length; ++index) { | 216 for (var index = 0; index < this.entries_.length; ++index) { |
207 var locationInfo = fm.volumeManager.getLocationInfo(this.entries_[index]); | 217 var locationInfo = fm.volumeManager.getLocationInfo(this.entries_[index]); |
208 if (locationInfo && locationInfo.isDriveBased) { | 218 if (locationInfo && locationInfo.isDriveBased) { |
209 isOnDrive = true; | 219 isOnDrive = true; |
210 break; | 220 break; |
211 } | 221 } |
212 } | 222 } |
213 | 223 |
214 for (var i = 0; i < tasks.length; i++) { | 224 for (var i = 0; i < tasks.length; i++) { |
215 var task = tasks[i]; | 225 var task = tasks[i]; |
216 var taskParts = task.taskId.split('|'); | 226 var taskParts = task.taskId.split('|'); |
217 | 227 |
218 // Skip internal Files.app's handlers. | 228 // Skip internal Files.app's handlers. |
219 if (taskParts[0] === id && (taskParts[2] === 'auto-open' || | 229 if (taskParts[0] === id && (taskParts[2] === 'auto-open' || |
220 taskParts[2] === 'select' || taskParts[2] === 'open')) { | 230 taskParts[2] === 'select' || taskParts[2] === 'open')) { |
221 continue; | 231 continue; |
222 } | 232 } |
223 | 233 |
234 // Skip video player app if multiple files are selected. | |
hirono
2014/03/28 05:35:22
Not so strong opinion.
How about filtering the tas
yoshiki
2014/03/28 06:53:10
Done.
| |
235 if (isMultiple && | |
236 taskParts[0] === FileTasks.VIDEO_PLAYER_ID && | |
237 taskParts[1] === 'app' && | |
238 taskParts[2] === 'video') { | |
239 continue; | |
240 } | |
241 | |
242 // Skip gallaly (video mode) if a single files is selected. | |
243 if (!isMultiple && | |
244 taskParts[0] === id && | |
245 taskParts[1] === 'file' && | |
246 taskParts[2] === 'gallery-video') { | |
247 continue; | |
248 } | |
249 | |
224 // Tweak images, titles of internal tasks. | 250 // Tweak images, titles of internal tasks. |
225 if (taskParts[0] === id && taskParts[1] === 'file') { | 251 if (taskParts[0] === id && taskParts[1] === 'file') { |
226 if (taskParts[2] === 'play') { | 252 if (taskParts[2] === 'play') { |
227 // TODO(serya): This hack needed until task.iconUrl is working | 253 // TODO(serya): This hack needed until task.iconUrl is working |
228 // (see GetFileTasksFileBrowserFunction::RunImpl). | 254 // (see GetFileTasksFileBrowserFunction::RunImpl). |
229 task.iconType = 'audio'; | 255 task.iconType = 'audio'; |
230 task.title = loadTimeData.getString('ACTION_LISTEN'); | 256 task.title = loadTimeData.getString('ACTION_LISTEN'); |
231 } else if (taskParts[2] === 'mount-archive') { | 257 } else if (taskParts[2] === 'mount-archive') { |
232 task.iconType = 'archive'; | 258 task.iconType = 'archive'; |
233 task.title = loadTimeData.getString('MOUNT_ARCHIVE'); | 259 task.title = loadTimeData.getString('MOUNT_ARCHIVE'); |
234 } else if (taskParts[2] === 'gallery') { | 260 } else if (taskParts[2] === 'gallery' || |
261 taskParts[2] === 'gallery-video') { | |
235 task.iconType = 'image'; | 262 task.iconType = 'image'; |
236 task.title = loadTimeData.getString('ACTION_OPEN'); | 263 task.title = loadTimeData.getString('ACTION_OPEN'); |
237 } else if (taskParts[2] === 'open-hosted-generic') { | 264 } else if (taskParts[2] === 'open-hosted-generic') { |
238 if (this.entries_.length > 1) | 265 if (this.entries_.length > 1) |
hirono
2014/03/28 05:35:22
isMultiple
| |
239 task.iconType = 'generic'; | 266 task.iconType = 'generic'; |
240 else // Use specific icon. | 267 else // Use specific icon. |
241 task.iconType = FileType.getIcon(this.entries_[0]); | 268 task.iconType = FileType.getIcon(this.entries_[0]); |
242 task.title = loadTimeData.getString('ACTION_OPEN'); | 269 task.title = loadTimeData.getString('ACTION_OPEN'); |
243 } else if (taskParts[2] === 'open-hosted-gdoc') { | 270 } else if (taskParts[2] === 'open-hosted-gdoc') { |
244 task.iconType = 'gdoc'; | 271 task.iconType = 'gdoc'; |
245 task.title = loadTimeData.getString('ACTION_OPEN_GDOC'); | 272 task.title = loadTimeData.getString('ACTION_OPEN_GDOC'); |
246 } else if (taskParts[2] === 'open-hosted-gsheet') { | 273 } else if (taskParts[2] === 'open-hosted-gsheet') { |
247 task.iconType = 'gsheet'; | 274 task.iconType = 'gsheet'; |
248 task.title = loadTimeData.getString('ACTION_OPEN_GSHEET'); | 275 task.title = loadTimeData.getString('ACTION_OPEN_GSHEET'); |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
545 displayedId); | 572 displayedId); |
546 }); | 573 }); |
547 return; | 574 return; |
548 } | 575 } |
549 | 576 |
550 if (id === 'mount-archive') { | 577 if (id === 'mount-archive') { |
551 this.mountArchivesInternal_(entries); | 578 this.mountArchivesInternal_(entries); |
552 return; | 579 return; |
553 } | 580 } |
554 | 581 |
555 if (id === 'gallery') { | 582 if (id === 'gallery' || id === 'gallery-video') { |
556 this.openGalleryInternal_(entries); | 583 this.openGalleryInternal_(entries); |
557 return; | 584 return; |
558 } | 585 } |
559 | 586 |
560 console.error('Unexpected action ID: ' + id); | 587 console.error('Unexpected action ID: ' + id); |
561 }; | 588 }; |
562 | 589 |
563 /** | 590 /** |
564 * Mounts archives. | 591 * Mounts archives. |
565 * | 592 * |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
850 this.pendingInvocations_.push([privateMethod, arguments]); | 877 this.pendingInvocations_.push([privateMethod, arguments]); |
851 } | 878 } |
852 return this; | 879 return this; |
853 }; | 880 }; |
854 }; | 881 }; |
855 | 882 |
856 FileTasks.decorate('display'); | 883 FileTasks.decorate('display'); |
857 FileTasks.decorate('updateMenuItem'); | 884 FileTasks.decorate('updateMenuItem'); |
858 FileTasks.decorate('execute'); | 885 FileTasks.decorate('execute'); |
859 FileTasks.decorate('executeDefault'); | 886 FileTasks.decorate('executeDefault'); |
OLD | NEW |