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..8a0e5038658f6c09e6ee0033543825effbd50edb 100644 |
| --- a/ui/file_manager/video_player/js/background.js |
| +++ b/ui/file_manager/video_player/js/background.js |
| @@ -70,19 +70,38 @@ function onLaunched(launchData) { |
| * @param {Array.<Object>} videos List of videos to play. |
|
hirono
2014/08/20 04:14:06
nit: @return
yoshiki
2014/08/20 04:26:21
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); |
|
hirono
2014/08/20 04:14:06
How about doing: return Promise.reject(error) ?
It
yoshiki
2014/08/20 04:26:21
Done.
|
| + }); |
| +} |
| + |
| +// 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); |
| + }); |
| } |