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..c0720ed0f347f52ceee76e35119dc96af1a0324b 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 |
| +// is finished, not to use an audioPlayer object before initializiation. |
| +var closuresDeferredUntilAudioPlayerInitialization = new AsyncUtil.Queue(); |
| + |
| +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); |
| + // Execute closures which uses the audioPlayer object. |
| + 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
|
| + closuresDeferredUntilAudioPlayerInitialization = null; |
| +}); |
| /** |
| * Launch the audio player. |
| * @param {Object} playlist Playlist. |
| */ |
| function launchAudioPlayer(playlist) { |
| - audioPlayer.launch(playlist); |
| + if (audioPlayer) { |
| + audioPlayer.launch(playlist); |
| + } else { |
| + 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.
|
| + launchAudioPlayer.bind(null, playlist)); |
| + } |
| } |
| var videoPlayer = new SingletonAppWindowWrapper('video_player.html', |
| @@ -745,8 +763,16 @@ Background.prototype.onRestarted_ = function() { |
| } |
| }); |
| - // Reopen sub-applications. |
| - audioPlayer.reopen(); |
| + // Reopen audio player. |
| + if (audioPlayer) { |
| + audioPlayer.reopen(); |
| + } else { |
| + closuresDeferredUntilAudioPlayerInitialization.run(function() { |
| + audioPlayer.reopen(); |
| + }); |
| + } |
| + |
| + // Reopen video player. |
| videoPlayer.reopen(); |
| }; |