Chromium Code Reviews| 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 * Number of runtime errors catched in the background page. | 8 * Number of runtime errors catched in the background page. |
| 9 * @type {number} | 9 * @type {number} |
| 10 */ | 10 */ |
| (...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 659 // For mounted devices just focus any Files.app window. The mounted | 659 // For mounted devices just focus any Files.app window. The mounted |
| 660 // volume will appear on the navigation list. | 660 // volume will appear on the navigation list. |
| 661 var type = action == 'auto-open' ? LaunchType.FOCUS_ANY_OR_CREATE : | 661 var type = action == 'auto-open' ? LaunchType.FOCUS_ANY_OR_CREATE : |
| 662 LaunchType.FOCUS_SAME_OR_CREATE; | 662 LaunchType.FOCUS_SAME_OR_CREATE; |
| 663 launchFileManager(appState, /* App ID */ undefined, type, nextStep); | 663 launchFileManager(appState, /* App ID */ undefined, type, nextStep); |
| 664 }); | 664 }); |
| 665 break; | 665 break; |
| 666 } | 666 } |
| 667 }; | 667 }; |
| 668 | 668 |
| 669 /** | 669 var audioPlayer = null; |
| 670 * Audio player window create options. | 670 // Stores closures to be executed after the initialization of the audio player |
| 671 * @type {Object} | 671 // is finished, not to use an audioPlayer object before initializiation. |
| 672 * @const | 672 var closuresDeferredUntilAudioPlayerInitialization = new AsyncUtil.Queue(); |
| 673 */ | 673 |
| 674 var AUDIO_PLAYER_CREATE_OPTIONS = Object.freeze({ | 674 chrome.commandLinePrivate.hasSwitch( |
| 675 type: 'panel', | 675 'file-manager-enable-new-audio-player', function(newAudioPlayerEnabled) { |
| 676 hidden: true, | 676 var audioPlayerHTML = |
| 677 minHeight: 35 + 58, | 677 newAudioPlayerEnabled ? 'audio_player.html' : 'mediaplayer.html'; |
| 678 minWidth: 280, | 678 |
| 679 height: 35 + 58, | 679 /** |
| 680 width: 280 | 680 * Audio player window create options. |
| 681 * @type {Object} | |
| 682 */ | |
| 683 var audioPlayerCreateOptions = Object.freeze({ | |
| 684 type: 'panel', | |
| 685 hidden: true, | |
| 686 minHeight: newAudioPlayerEnabled ? 116 : (35 + 58), | |
| 687 minWidth: newAudioPlayerEnabled ? 292 : 280, | |
| 688 height: newAudioPlayerEnabled ? 356 : (35 + 58), | |
| 689 width: newAudioPlayerEnabled ? 292 : 280, | |
| 690 }); | |
| 691 | |
| 692 audioPlayer = new SingletonAppWindowWrapper(audioPlayerHTML, | |
| 693 audioPlayerCreateOptions); | |
| 694 // Execute closures which uses the audioPlayer object. | |
| 695 closuresDeferredUntilAudioPlayerInitialization.run(); | |
|
mtomasz
2014/01/27 09:43:39
I think this should be removed. Queue.run() withou
yoshiki
2014/01/28 05:57:56
Thanks. I was confusing about Queue and Group. I c
| |
| 696 closuresDeferredUntilAudioPlayerInitialization = null; | |
| 681 }); | 697 }); |
| 682 | 698 |
| 683 var audioPlayer = new SingletonAppWindowWrapper('mediaplayer.html', | |
| 684 AUDIO_PLAYER_CREATE_OPTIONS); | |
| 685 | |
| 686 /** | 699 /** |
| 687 * Launch the audio player. | 700 * Launch the audio player. |
| 688 * @param {Object} playlist Playlist. | 701 * @param {Object} playlist Playlist. |
| 689 */ | 702 */ |
| 690 function launchAudioPlayer(playlist) { | 703 function launchAudioPlayer(playlist) { |
| 691 audioPlayer.launch(playlist); | 704 if (audioPlayer) { |
| 705 audioPlayer.launch(playlist); | |
| 706 } else { | |
| 707 closuresDeferredUntilAudioPlayerInitialization.run( | |
|
mtomasz
2014/01/27 09:43:39
I think this doesn't work as intended. Since the q
yoshiki
2014/01/28 05:57:56
You're correct. I was confusing.
| |
| 708 launchAudioPlayer.bind(null, playlist)); | |
| 709 } | |
| 692 } | 710 } |
| 693 | 711 |
| 694 var videoPlayer = new SingletonAppWindowWrapper('video_player.html', | 712 var videoPlayer = new SingletonAppWindowWrapper('video_player.html', |
| 695 {hidden: true}); | 713 {hidden: true}); |
| 696 | 714 |
| 697 /** | 715 /** |
| 698 * Launch the video player. | 716 * Launch the video player. |
| 699 * @param {string} url Video url. | 717 * @param {string} url Video url. |
| 700 */ | 718 */ |
| 701 function launchVideoPlayer(url) { | 719 function launchVideoPlayer(url) { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 738 var appState = JSON.parse(items[key]); | 756 var appState = JSON.parse(items[key]); |
| 739 launchFileManager(appState, id); | 757 launchFileManager(appState, id); |
| 740 } catch (e) { | 758 } catch (e) { |
| 741 console.error('Corrupt launch data for ' + id); | 759 console.error('Corrupt launch data for ' + id); |
| 742 } | 760 } |
| 743 } | 761 } |
| 744 } | 762 } |
| 745 } | 763 } |
| 746 }); | 764 }); |
| 747 | 765 |
| 748 // Reopen sub-applications. | 766 // Reopen audio player. |
| 749 audioPlayer.reopen(); | 767 if (audioPlayer) { |
| 768 audioPlayer.reopen(); | |
| 769 } else { | |
| 770 closuresDeferredUntilAudioPlayerInitialization.run(function() { | |
| 771 audioPlayer.reopen(); | |
| 772 }); | |
| 773 } | |
| 774 | |
| 775 // Reopen video player. | |
| 750 videoPlayer.reopen(); | 776 videoPlayer.reopen(); |
| 751 }; | 777 }; |
| 752 | 778 |
| 753 /** | 779 /** |
| 754 * Handles clicks on a custom item on the launcher context menu. | 780 * Handles clicks on a custom item on the launcher context menu. |
| 755 * @param {OnClickData} info Event details. | 781 * @param {OnClickData} info Event details. |
| 756 * @private | 782 * @private |
| 757 */ | 783 */ |
| 758 Background.prototype.onContextMenuClicked_ = function(info) { | 784 Background.prototype.onContextMenuClicked_ = function(info) { |
| 759 if (info.menuItemId == 'new-window') { | 785 if (info.menuItemId == 'new-window') { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 796 contexts: ['launcher'], | 822 contexts: ['launcher'], |
| 797 title: str('NEW_WINDOW_BUTTON_LABEL') | 823 title: str('NEW_WINDOW_BUTTON_LABEL') |
| 798 }); | 824 }); |
| 799 }; | 825 }; |
| 800 | 826 |
| 801 /** | 827 /** |
| 802 * Singleton instance of Background. | 828 * Singleton instance of Background. |
| 803 * @type {Background} | 829 * @type {Background} |
| 804 */ | 830 */ |
| 805 window.background = new Background(); | 831 window.background = new Background(); |
| OLD | NEW |