Index: ui/file_manager/gallery/js/background.js |
diff --git a/ui/file_manager/gallery/js/background.js b/ui/file_manager/gallery/js/background.js |
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..96a86daa4154eec4478d0acd8d6dd790136b0b82 100644 |
--- a/ui/file_manager/gallery/js/background.js |
+++ b/ui/file_manager/gallery/js/background.js |
@@ -0,0 +1,47 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+'use strict'; |
+ |
+var stringData = new Promise(function(fulfill) { |
+ chrome.fileBrowserPrivate.getStrings(function(stringData) { |
+ loadTimeData.data = stringData; |
+ fulfill(stringData); |
+ }); |
+}); |
+ |
+// VolumeManager should be obtained after stringData initialized. |
+var volumeManager = stringData.then(function() { |
+ return new Promise(function(fulfill) { |
+ VolumeManager.getInstance(fulfill); |
+ }); |
+}); |
+ |
+var backgroundComponent = Promise.all([stringData, volumeManager]). |
+ then(function(args) { |
+ return { |
+ stringData: args[0], |
+ volumeManager: args[1] |
+ }; |
+ }); |
+ |
+chrome.app.runtime.onLaunched.addListener(function(launchData) { |
+ // Skip if files are not selected. |
+ if (!launchData || !launchData.items || launchData.items.length == 0) |
+ return; |
+ |
+ // Open application window. |
+ chrome.app.window.create( |
+ 'gallery.html', |
+ { |
+ id: 'video', |
+ minWidth: 160, |
+ minHeight: 100, |
+ frame: 'none' |
+ }, |
+ function(appWindow) { |
+ appWindow.contentWindow.launchData = launchData; |
+ appWindow.contentWindow.backgroundComponent = backgroundComponent; |
+ }); |
+}); |