| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 'use strict'; | 5 'use strict'; |
| 6 | 6 |
| 7 // Stores the app windows OLNY for test purpose. | 7 // Stores the app windows OLNY for test purpose. |
| 8 // We SHOULD NOT use it as it is except for test, since the files which have | 8 // We SHOULD NOT use it as it is except for test, since the files which have |
| 9 // the same name will be overridden each other. | 9 // the same name will be overridden each other. |
| 10 var appWindowsForTest = {}; | 10 var appWindowsForTest = {}; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 // TODO(yoshiki): handle error in a smarter way. | 61 // TODO(yoshiki): handle error in a smarter way. |
| 62 open('', 'error'); // Empty URL shows the error message. | 62 open('', 'error'); // Empty URL shows the error message. |
| 63 } | 63 } |
| 64 fulfill(); | 64 fulfill(); |
| 65 }.wrap()); | 65 }.wrap()); |
| 66 } | 66 } |
| 67 | 67 |
| 68 /** | 68 /** |
| 69 * Opens player window. | 69 * Opens player window. |
| 70 * @param {Array.<Object>} videos List of videos to play. | 70 * @param {Array.<Object>} videos List of videos to play. |
| 71 * @param {Promise} Promise to be fulfilled on success, or rejected on error. | 71 * @return {Promise} Promise to be fulfilled on success, or rejected on error. |
| 72 */ | 72 */ |
| 73 function open(videos) { | 73 function open(videos) { |
| 74 return new Promise(function(fulfill, reject) { | 74 return new Promise(function(fulfill, reject) { |
| 75 chrome.app.window.create('video_player.html', { | 75 chrome.app.window.create('video_player.html', { |
| 76 id: 'video', | 76 id: 'video', |
| 77 frame: 'none', | 77 frame: 'none', |
| 78 singleton: false, | 78 singleton: false, |
| 79 minWidth: 480, | 79 minWidth: 480, |
| 80 minHeight: 270 | 80 minHeight: 270 |
| 81 }, | 81 }, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 93 chrome.runtime.sendMessage({ready: true}); | 93 chrome.runtime.sendMessage({ready: true}); |
| 94 }).catch(function(error) { | 94 }).catch(function(error) { |
| 95 console.error('Launch failed', error.stack || error); | 95 console.error('Launch failed', error.stack || error); |
| 96 return Promise.reject(error); | 96 return Promise.reject(error); |
| 97 }); | 97 }); |
| 98 } | 98 } |
| 99 | 99 |
| 100 // If is is run in the browser test, wait for the test resources are installed | 100 // If is is run in the browser test, wait for the test resources are installed |
| 101 // as a component extension, and then load the test resources. | 101 // as a component extension, and then load the test resources. |
| 102 if (chrome.test) { | 102 if (chrome.test) { |
| 103 /** @type {string} */ |
| 103 window.testExtensionId = 'ljoplibgfehghmibaoaepfagnmbbfiga'; | 104 window.testExtensionId = 'ljoplibgfehghmibaoaepfagnmbbfiga'; |
| 104 chrome.runtime.onMessageExternal.addListener(function(message) { | 105 chrome.runtime.onMessageExternal.addListener(function(message) { |
| 105 if (message.name !== 'testResourceLoaded') | 106 if (message.name !== 'testResourceLoaded') |
| 106 return; | 107 return; |
| 107 var script = document.createElement('script'); | 108 var script = document.createElement('script'); |
| 108 script.src = | 109 script.src = |
| 109 'chrome-extension://' + window.testExtensionId + | 110 'chrome-extension://' + window.testExtensionId + |
| 110 '/common/test_loader.js'; | 111 '/common/test_loader.js'; |
| 111 document.documentElement.appendChild(script); | 112 document.documentElement.appendChild(script); |
| 112 }); | 113 }); |
| 113 } | 114 } |
| OLD | NEW |