Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(594)

Unified Diff: ui/file_manager/gallery/js/gallery.js

Issue 921043004: [Gallery app] Make the background page use BackgroundBase class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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();
+ });
};

Powered by Google App Engine
This is Rietveld 408576698