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 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
529 /** | 529 /** |
530 * Executes an internal task. | 530 * Executes an internal task. |
531 * | 531 * |
532 * @param {string} id The short task id. | 532 * @param {string} id The short task id. |
533 * @param {Array.<Entry>} entries The entries to execute on. | 533 * @param {Array.<Entry>} entries The entries to execute on. |
534 * @private | 534 * @private |
535 */ | 535 */ |
536 FileTasks.prototype.executeInternalTask_ = function(id, entries) { | 536 FileTasks.prototype.executeInternalTask_ = function(id, entries) { |
537 var fm = this.fileManager_; | 537 var fm = this.fileManager_; |
538 | 538 |
539 if (id === 'play') { | |
540 var selectedEntry = entries[0]; | |
541 if (entries.length === 1) { | |
542 // If just a single audio file is selected pass along every audio file | |
543 // in the directory. | |
544 entries = fm.getAllEntriesInCurrentDirectory().filter(FileType.isAudio); | |
545 } | |
546 // TODO(mtomasz): Move conversion from entry to url to custom bindings. | |
547 // crbug.com/345527. | |
548 var urls = util.entriesToURLs(entries); | |
549 var position = urls.indexOf(selectedEntry.toURL()); | |
550 chrome.fileManagerPrivate.getProfiles( | |
551 function(profiles, currentId, displayedId) { | |
552 fm.backgroundPage.launchAudioPlayer( | |
553 {items: urls, position: position}, displayedId); | |
554 }); | |
555 return; | |
556 } | |
557 | |
558 if (id === 'mount-archive') { | 539 if (id === 'mount-archive') { |
559 this.mountArchivesInternal_(entries); | 540 this.mountArchivesInternal_(entries); |
560 return; | 541 return; |
561 } | 542 } |
562 | 543 |
563 console.error('Unexpected action ID: ' + id); | 544 console.error('Unexpected action ID: ' + id); |
564 }; | 545 }; |
565 | 546 |
566 /** | 547 /** |
567 * Mounts archives. | 548 * Mounts archives. |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
751 this.pendingInvocations_.push([privateMethod, arguments]); | 732 this.pendingInvocations_.push([privateMethod, arguments]); |
752 } | 733 } |
753 return this; | 734 return this; |
754 }; | 735 }; |
755 }; | 736 }; |
756 | 737 |
757 FileTasks.decorate('display'); | 738 FileTasks.decorate('display'); |
758 FileTasks.decorate('updateMenuItem'); | 739 FileTasks.decorate('updateMenuItem'); |
759 FileTasks.decorate('execute'); | 740 FileTasks.decorate('execute'); |
760 FileTasks.decorate('executeDefault'); | 741 FileTasks.decorate('executeDefault'); |
OLD | NEW |