Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2185)

Unified Diff: chrome/browser/resources/file_manager/background/js/background.js

Issue 144883002: [Files.app] Initial implementation of new audio player (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Make the script/css files flattened. Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 edd3620feb42131f241e0c66079347db9d6ee296..9783badf4b38d2dd662c665f623aba181d0460b0 100644
--- a/chrome/browser/resources/file_manager/background/js/background.js
+++ b/chrome/browser/resources/file_manager/background/js/background.js
@@ -683,29 +683,48 @@ 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
-});
+// The instance of audio player. Until it's ready, this is null.
+var audioPlayer = null;
+
+// Queue to serializes the initialization, launching and reloading of the audio
+// player, so races won't happen.
+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',
@@ -762,8 +781,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();
};
« no previous file with comments | « chrome/browser/resources/file_manager/audio_player/js/audio_player_scripts.js ('k') | chromeos/chromeos_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698