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
3 // found in the LICENSE file.
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
9 // the same name will be overridden each other.
10 var appWindowsForTest = {};
12 var initializeQueue = new AsyncUtil.Queue();
14 // Initializes the strings. This needs for the volume manager.
15 initializeQueue.run(function(fulfill) {
16 chrome.fileBrowserPrivate.getStrings(function(stringData) {
17 loadTimeData.data = stringData;
22 // Initializes the volume manager. This needs for isolated entries.
23 initializeQueue.run(function(fulfill) {
24 VolumeManager.getInstance(fulfill);
27 chrome.app.runtime.onLaunched.addListener(onLaunched);
30 * Called when an app is launched.
31 * @param {Object} launchData Launch data.
33 function onLaunched(launchData) {
34 if (!launchData || !launchData.items || launchData.items.length == 0)
39 initializeQueue.run(function(fulfill) {
40 var isolatedEntries = launchData.items.map(function(item) {
44 chrome.fileBrowserPrivate.resolveIsolatedEntries(isolatedEntries,
45 function(externalEntries) {
46 videos = externalEntries.map(function(entry) {
47 return Object.freeze({
57 initializeQueue.run(function(fulfill) {
58 if (videos.length > 0) {
61 // TODO(yoshiki): handle error in a smarter way.
62 open('', 'error'); // Empty URL shows the error message.
69 * Opens player window.
70 * @param {Array.<Object>} videos List of videos to play.
72 function open(videos) {
73 chrome.app.window.create('video_player.html', {
80 function(createdWindow) {
81 // Stores the window for test purpose.
82 appWindowsForTest[videos[0].entry.name] = createdWindow;
84 createdWindow.setIcon('images/icon/video-player-64.png');
85 createdWindow.contentWindow.videos = videos;
86 chrome.runtime.sendMessage({ready: true}, function() {});