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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 */ | 181 */ |
182 FileTasks.isInternalTask_ = function(taskId) { | 182 FileTasks.isInternalTask_ = function(taskId) { |
183 var taskParts = taskId.split('|'); | 183 var taskParts = taskId.split('|'); |
184 var appId = taskParts[0]; | 184 var appId = taskParts[0]; |
185 var taskType = taskParts[1]; | 185 var taskType = taskParts[1]; |
186 var actionId = taskParts[2]; | 186 var actionId = taskParts[2]; |
187 // The action IDs here should match ones used in executeInternalTask_(). | 187 // The action IDs here should match ones used in executeInternalTask_(). |
188 return (appId === chrome.runtime.id && | 188 return (appId === chrome.runtime.id && |
189 taskType === 'file' && | 189 taskType === 'file' && |
190 (actionId === 'play' || | 190 (actionId === 'play' || |
191 actionId === 'watch' || | |
192 actionId === 'mount-archive' || | 191 actionId === 'mount-archive' || |
193 actionId === 'gallery')); | 192 actionId === 'gallery')); |
194 }; | 193 }; |
195 | 194 |
196 /** | 195 /** |
197 * Processes internal tasks. | 196 * Processes internal tasks. |
198 * | 197 * |
199 * @param {Array.<Object>} tasks The tasks. | 198 * @param {Array.<Object>} tasks The tasks. |
200 * @private | 199 * @private |
201 */ | 200 */ |
(...skipping 26 matching lines...) Expand all Loading... |
228 // TODO(serya): This hack needed until task.iconUrl is working | 227 // TODO(serya): This hack needed until task.iconUrl is working |
229 // (see GetFileTasksFileBrowserFunction::RunImpl). | 228 // (see GetFileTasksFileBrowserFunction::RunImpl). |
230 task.iconType = 'audio'; | 229 task.iconType = 'audio'; |
231 task.title = loadTimeData.getString('ACTION_LISTEN'); | 230 task.title = loadTimeData.getString('ACTION_LISTEN'); |
232 } else if (taskParts[2] === 'mount-archive') { | 231 } else if (taskParts[2] === 'mount-archive') { |
233 task.iconType = 'archive'; | 232 task.iconType = 'archive'; |
234 task.title = loadTimeData.getString('MOUNT_ARCHIVE'); | 233 task.title = loadTimeData.getString('MOUNT_ARCHIVE'); |
235 } else if (taskParts[2] === 'gallery') { | 234 } else if (taskParts[2] === 'gallery') { |
236 task.iconType = 'image'; | 235 task.iconType = 'image'; |
237 task.title = loadTimeData.getString('ACTION_OPEN'); | 236 task.title = loadTimeData.getString('ACTION_OPEN'); |
238 } else if (taskParts[2] === 'watch') { | |
239 task.iconType = 'video'; | |
240 task.title = loadTimeData.getString('ACTION_WATCH'); | |
241 } else if (taskParts[2] === 'open-hosted-generic') { | 237 } else if (taskParts[2] === 'open-hosted-generic') { |
242 if (this.entries_.length > 1) | 238 if (this.entries_.length > 1) |
243 task.iconType = 'generic'; | 239 task.iconType = 'generic'; |
244 else // Use specific icon. | 240 else // Use specific icon. |
245 task.iconType = FileType.getIcon(this.entries_[0]); | 241 task.iconType = FileType.getIcon(this.entries_[0]); |
246 task.title = loadTimeData.getString('ACTION_OPEN'); | 242 task.title = loadTimeData.getString('ACTION_OPEN'); |
247 } else if (taskParts[2] === 'open-hosted-gdoc') { | 243 } else if (taskParts[2] === 'open-hosted-gdoc') { |
248 task.iconType = 'gdoc'; | 244 task.iconType = 'gdoc'; |
249 task.title = loadTimeData.getString('ACTION_OPEN_GDOC'); | 245 task.title = loadTimeData.getString('ACTION_OPEN_GDOC'); |
250 } else if (taskParts[2] === 'open-hosted-gsheet') { | 246 } else if (taskParts[2] === 'open-hosted-gsheet') { |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
544 var urls = util.entriesToURLs(entries); | 540 var urls = util.entriesToURLs(entries); |
545 chrome.fileBrowserPrivate.getProfiles(function(profiles, | 541 chrome.fileBrowserPrivate.getProfiles(function(profiles, |
546 currentId, | 542 currentId, |
547 displayedId) { | 543 displayedId) { |
548 fm.backgroundPage.launchAudioPlayer({items: urls, position: position}, | 544 fm.backgroundPage.launchAudioPlayer({items: urls, position: position}, |
549 displayedId); | 545 displayedId); |
550 }); | 546 }); |
551 return; | 547 return; |
552 } | 548 } |
553 | 549 |
554 if (id === 'watch') { | |
555 console.assert(entries.length === 1, 'Cannot open multiple videos'); | |
556 // TODO(mtomasz): Pass an entry instead. | |
557 chrome.fileBrowserPrivate.getProfiles(function(profiles, | |
558 currentId, | |
559 displayedId) { | |
560 fm.backgroundPage.launchVideoPlayer(entries[0].toURL(), displayedId); | |
561 }); | |
562 return; | |
563 } | |
564 | |
565 if (id === 'mount-archive') { | 550 if (id === 'mount-archive') { |
566 this.mountArchivesInternal_(entries); | 551 this.mountArchivesInternal_(entries); |
567 return; | 552 return; |
568 } | 553 } |
569 | 554 |
570 if (id === 'gallery') { | 555 if (id === 'gallery') { |
571 this.openGalleryInternal_(entries); | 556 this.openGalleryInternal_(entries); |
572 return; | 557 return; |
573 } | 558 } |
574 | 559 |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
872 this.pendingInvocations_.push([privateMethod, arguments]); | 857 this.pendingInvocations_.push([privateMethod, arguments]); |
873 } | 858 } |
874 return this; | 859 return this; |
875 }; | 860 }; |
876 }; | 861 }; |
877 | 862 |
878 FileTasks.decorate('display'); | 863 FileTasks.decorate('display'); |
879 FileTasks.decorate('updateMenuItem'); | 864 FileTasks.decorate('updateMenuItem'); |
880 FileTasks.decorate('execute'); | 865 FileTasks.decorate('execute'); |
881 FileTasks.decorate('executeDefault'); | 866 FileTasks.decorate('executeDefault'); |
OLD | NEW |