Chromium Code Reviews| Index: chrome/browser/resources/file_manager/background/js/background.js |
| diff --git a/chrome/browser/resources/file_manager/background/js/background.js b/chrome/browser/resources/file_manager/background/js/background.js |
| index 94e850e3bf99bafc8b34d45769f9f7f0acc5f346..5d350bad1042cc4083eb5d1ab6bb5d89252b0b94 100644 |
| --- a/chrome/browser/resources/file_manager/background/js/background.js |
| +++ b/chrome/browser/resources/file_manager/background/js/background.js |
| @@ -666,29 +666,47 @@ Background.prototype.onExecute_ = function(action, details) { |
| } |
| }; |
| -/** |
| - * Audio player window create options. |
| - * @type {Object} |
| - * @const |
| - */ |
| -var AUDIO_PLAYER_CREATE_OPTIONS = Object.freeze({ |
| - type: 'panel', |
| - hidden: true, |
| - minHeight: 35 + 58, |
| - minWidth: 280, |
| - height: 35 + 58, |
| - width: 280 |
| -}); |
| +var audioPlayer = null; |
| + |
| +// Stores closures to be executed after the initialization of the audio player |
|
mtomasz
2014/01/28 06:09:45
nit: Please update the comment.
yoshiki
2014/01/28 08:31:42
Done.
|
| +// is finished, not to use an audioPlayer object before initializiation. |
| +var audioPlayerInitializationQueue = new AsyncUtil.Queue(); |
| + |
| +audioPlayerInitializationQueue.run(function(callback) { |
| + chrome.commandLinePrivate.hasSwitch( |
| + 'file-manager-enable-new-audio-player', |
| + function(newAudioPlayerEnabled) { |
| + var audioPlayerHTML = |
| + newAudioPlayerEnabled ? 'audio_player.html' : 'mediaplayer.html'; |
| + |
| + /** |
| + * Audio player window create options. |
| + * @type {Object} |
| + */ |
| + var audioPlayerCreateOptions = Object.freeze({ |
| + type: 'panel', |
| + hidden: true, |
| + minHeight: newAudioPlayerEnabled ? 116 : (35 + 58), |
| + minWidth: newAudioPlayerEnabled ? 292 : 280, |
| + height: newAudioPlayerEnabled ? 356 : (35 + 58), |
| + width: newAudioPlayerEnabled ? 292 : 280, |
| + }); |
| -var audioPlayer = new SingletonAppWindowWrapper('mediaplayer.html', |
| - AUDIO_PLAYER_CREATE_OPTIONS); |
| + audioPlayer = new SingletonAppWindowWrapper(audioPlayerHTML, |
| + audioPlayerCreateOptions); |
| + callback(); |
| + }); |
| +}); |
| /** |
| * Launch the audio player. |
| * @param {Object} playlist Playlist. |
| */ |
| function launchAudioPlayer(playlist) { |
| - audioPlayer.launch(playlist); |
| + audioPlayerInitializationQueue.run(function(callback) { |
| + audioPlayer.launch(playlist); |
| + callback(); |
| + }); |
| } |
| var videoPlayer = new SingletonAppWindowWrapper('video_player.html', |
| @@ -745,8 +763,13 @@ Background.prototype.onRestarted_ = function() { |
| } |
| }); |
| - // Reopen sub-applications. |
| - audioPlayer.reopen(); |
| + // Reopen audio player. |
| + audioPlayerInitializationQueue.run(function(callback) { |
| + audioPlayer.reopen(); |
| + callback(); |
| + }); |
| + |
| + // Reopen video player. |
| videoPlayer.reopen(); |
| }; |