Chromium Code Reviews| Index: ui/file_manager/video_player/js/background.js |
| diff --git a/ui/file_manager/video_player/js/background.js b/ui/file_manager/video_player/js/background.js |
| index 3f82301f9531e1675af588dc9cbd07cbde5db1c9..f1cee4a6c512504cb8303971111412f6a9479a97 100644 |
| --- a/ui/file_manager/video_player/js/background.js |
| +++ b/ui/file_manager/video_player/js/background.js |
| @@ -68,21 +68,42 @@ function onLaunched(launchData) { |
| /** |
| * Opens player window. |
| * @param {Array.<Object>} videos List of videos to play. |
| + * @param {Primise} Promise to be fulfilled on success, or rejected on error. |
|
hirono
2014/08/20 04:33:28
typo: Primise -> Promise
yoshiki
2014/08/20 06:18:14
Done.
|
| */ |
| function open(videos) { |
| - chrome.app.window.create('video_player.html', { |
| - id: 'video', |
| - frame: 'none', |
| - singleton: false, |
| - minWidth: 480, |
| - minHeight: 270 |
| - }, |
| - function(createdWindow) { |
| + return new Promise(function(fulfill, reject) { |
| + chrome.app.window.create('video_player.html', { |
| + id: 'video', |
| + frame: 'none', |
| + singleton: false, |
| + minWidth: 480, |
| + minHeight: 270 |
| + }, |
| + fulfill); |
| + }).then(function(createdWindow) { |
| // Stores the window for test purpose. |
| appWindowsForTest[videos[0].entry.name] = createdWindow; |
| createdWindow.setIcon('images/icon/video-player-64.png'); |
| createdWindow.contentWindow.videos = videos; |
| chrome.runtime.sendMessage({ready: true}, function() {}); |
| - }.wrap()); |
| + }).catch(function(error) { |
| + console.error('Launch failed', error.stack || error); |
| + return Promise.reject(error); |
| + }); |
| +} |
| + |
| +// If is is run in the browser test, wait for the test resources are installed |
| +// as a component extension, and then load the test resources. |
| +if (chrome.test) { |
| + window.testExtensionId = 'ljoplibgfehghmibaoaepfagnmbbfiga'; |
| + chrome.runtime.onMessageExternal.addListener(function(message) { |
| + if (message.name !== 'testResourceLoaded') |
| + return; |
| + var script = document.createElement('script'); |
| + script.src = |
| + 'chrome-extension://' + window.testExtensionId + |
| + '/common/test_loader.js'; |
| + document.documentElement.appendChild(script); |
| + }); |
| } |