Index: ui/file_manager/gallery/js/gallery.js |
diff --git a/ui/file_manager/gallery/js/gallery.js b/ui/file_manager/gallery/js/gallery.js |
index 3df5c2d7ff46aafb3a84bc41cb52b1e540565df3..fe89a1d4733e1d62033a99cb7081fec42b41c91d 100644 |
--- a/ui/file_manager/gallery/js/gallery.js |
+++ b/ui/file_manager/gallery/js/gallery.js |
@@ -903,26 +903,47 @@ Gallery.prototype.debugMe = function() { |
*/ |
var gallery = null; |
+var loadTimeDataPromise = new Promise(function(fulfill, reject) { |
+ chrome.fileManagerPrivate.getStrings(function(strings) { |
+ window.loadTimeData.data = strings; |
+ i18nTemplate.process(document, loadTimeData); |
+ fulfill(); |
+ }); |
+}); |
+ |
/** |
* Initialize the window. |
* @param {!BackgroundComponents} backgroundComponents Background components. |
fukino
2015/02/16 04:16:38
nit: This comment looks incorrect.
yoshiki
2015/02/16 07:35:55
Done.
|
*/ |
-window.initialize = function(backgroundComponents) { |
- window.loadTimeData.data = backgroundComponents.stringData; |
- gallery = new Gallery(backgroundComponents.volumeManager); |
-}; |
+var volumeManagerPromise = new Promise(function(fulfill, reject) { |
+ var volumeManager = new VolumeManagerWrapper( |
+ VolumeManagerWrapper.DriveEnabledStatus.DRIVE_ENABLED); |
+ volumeManager.ensureInitialized(fulfill.bind(null, volumeManager)); |
+}); |
+ |
+var initializePromise = |
+ Promise.all([loadTimeDataPromise, volumeManagerPromise]). |
+ then(function(args) { |
+ var volumeManager = args[1]; |
+ var gallery = new Gallery(volumeManager); |
+ return gallery; |
+ }); |
/** |
* Loads entries. |
* @param {!Array.<Entry>} selectedEntries Array of selected entries. |
fukino
2015/02/16 04:16:38
ditto
yoshiki
2015/02/16 07:35:55
Done.
|
*/ |
-window.loadEntries = function(selectedEntries) { |
- gallery.load(selectedEntries); |
-}; |
+initializePromise.then(function(gallery) { |
+ util.URLsToEntries(window.appState.urls, function(entries) { |
+ gallery.load(entries); |
+ }); |
+}); |
/** |
* Enteres the debug mode. |
*/ |
window.debugMe = function() { |
- gallery.debugMe(); |
+ initializePromise.then(function(gallery) { |
+ gallery.debugMe(); |
+ }); |
}; |