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

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: rebased 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
« no previous file with comments | « ui/file_manager/gallery/js/compiled_resources.gyp ('k') | ui/file_manager/gallery/js/gallery_scripts.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 c5b74d1f2b04ad7bd205031c9ef3ce7a6d3b34ec..d25a6205510adeeab6722b72b1e2025a408df0fa 100644
--- a/ui/file_manager/gallery/js/gallery.js
+++ b/ui/file_manager/gallery/js/gallery.js
@@ -283,7 +283,7 @@ Gallery.prototype.initToolbarButton_ = function(className, title) {
/**
* Loads the content.
*
- * @param {!Array.<Entry>} selectedEntries Array of selected entries.
+ * @param {!Array.<!Entry>} selectedEntries Array of selected entries.
*/
Gallery.prototype.load = function(selectedEntries) {
GalleryUtil.createEntrySet(selectedEntries).then(function(allEntries) {
@@ -294,8 +294,8 @@ Gallery.prototype.load = function(selectedEntries) {
/**
* Loads the content.
*
- * @param {!Array.<Entry>} entries Array of entries.
- * @param {!Array.<Entry>} selectedEntries Array of selected entries.
+ * @param {!Array.<!Entry>} entries Array of entries.
+ * @param {!Array.<!Entry>} selectedEntries Array of selected entries.
* @private
*/
Gallery.prototype.loadInternal_ = function(entries, selectedEntries) {
@@ -908,25 +908,56 @@ Gallery.prototype.debugMe = function() {
var gallery = null;
/**
- * Initialize the window.
- * @param {!BackgroundComponents} backgroundComponents Background components.
+ * Promise to initialize the load time data.
+ * @type {!Promise}
*/
-window.initialize = function(backgroundComponents) {
- window.loadTimeData.data = backgroundComponents.stringData;
- gallery = new Gallery(backgroundComponents.volumeManager);
-};
+var loadTimeDataPromise = new Promise(function(fulfill, reject) {
+ chrome.fileManagerPrivate.getStrings(function(strings) {
+ window.loadTimeData.data = strings;
+ i18nTemplate.process(document, loadTimeData);
+ fulfill(true);
+ });
+});
/**
- * Loads entries.
- * @param {!Array.<Entry>} selectedEntries Array of selected entries.
+ * Promise to initialize volume manager.
+ * @type {!Promise}
*/
-window.loadEntries = function(selectedEntries) {
- gallery.load(selectedEntries);
-};
+var volumeManagerPromise = new Promise(function(fulfill, reject) {
+ var volumeManager = new VolumeManagerWrapper(
+ VolumeManagerWrapper.DriveEnabledStatus.DRIVE_ENABLED);
+ volumeManager.ensureInitialized(fulfill.bind(null, volumeManager));
+});
+
+/**
+ * Promise to initialize both the volume manager and the load time data.
+ * @type {!Promise}
+ */
+var initializePromise =
+ Promise.all([loadTimeDataPromise, volumeManagerPromise]).
+ then(function(args) {
+ var volumeManager = args[1];
+ var gallery = new Gallery(volumeManager);
+ return gallery;
+ });
+
+// Loads entries.
+initializePromise.then(
+ /**
+ * Loads entries.
+ * @param {!Gallery} gallery The gallery instance.
+ */
+ 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();
+ });
};
« no previous file with comments | « ui/file_manager/gallery/js/compiled_resources.gyp ('k') | ui/file_manager/gallery/js/gallery_scripts.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698