OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * Overrided metadata worker's path. | 6 * Overrided metadata worker's path. |
7 * @type {string} | 7 * @type {string} |
8 */ | 8 */ |
9 ContentProvider.WORKER_SCRIPT = '/js/metadata_worker.js'; | 9 ContentProvider.WORKER_SCRIPT = '/js/metadata_worker.js'; |
10 | 10 |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 */ | 276 */ |
277 Gallery.prototype.initToolbarButton_ = function(className, title) { | 277 Gallery.prototype.initToolbarButton_ = function(className, title) { |
278 var button = queryRequiredElement(this.toolbar_, 'button.' + className); | 278 var button = queryRequiredElement(this.toolbar_, 'button.' + className); |
279 button.title = str(title); | 279 button.title = str(title); |
280 return button; | 280 return button; |
281 }; | 281 }; |
282 | 282 |
283 /** | 283 /** |
284 * Loads the content. | 284 * Loads the content. |
285 * | 285 * |
286 * @param {!Array.<Entry>} selectedEntries Array of selected entries. | 286 * @param {!Array.<!Entry>} selectedEntries Array of selected entries. |
287 */ | 287 */ |
288 Gallery.prototype.load = function(selectedEntries) { | 288 Gallery.prototype.load = function(selectedEntries) { |
289 GalleryUtil.createEntrySet(selectedEntries).then(function(allEntries) { | 289 GalleryUtil.createEntrySet(selectedEntries).then(function(allEntries) { |
290 this.loadInternal_(allEntries, selectedEntries); | 290 this.loadInternal_(allEntries, selectedEntries); |
291 }.bind(this)); | 291 }.bind(this)); |
292 }; | 292 }; |
293 | 293 |
294 /** | 294 /** |
295 * Loads the content. | 295 * Loads the content. |
296 * | 296 * |
297 * @param {!Array.<Entry>} entries Array of entries. | 297 * @param {!Array.<!Entry>} entries Array of entries. |
298 * @param {!Array.<Entry>} selectedEntries Array of selected entries. | 298 * @param {!Array.<!Entry>} selectedEntries Array of selected entries. |
299 * @private | 299 * @private |
300 */ | 300 */ |
301 Gallery.prototype.loadInternal_ = function(entries, selectedEntries) { | 301 Gallery.prototype.loadInternal_ = function(entries, selectedEntries) { |
302 // Obtains max chank size. | 302 // Obtains max chank size. |
303 var maxChunkSize = 20; | 303 var maxChunkSize = 20; |
304 var volumeInfo = this.volumeManager_.getVolumeInfo(entries[0]); | 304 var volumeInfo = this.volumeManager_.getVolumeInfo(entries[0]); |
305 if (volumeInfo && | 305 if (volumeInfo && |
306 volumeInfo.volumeType === VolumeManagerCommon.VolumeType.MTP) { | 306 volumeInfo.volumeType === VolumeManagerCommon.VolumeType.MTP) { |
307 maxChunkSize = 1; | 307 maxChunkSize = 1; |
308 } | 308 } |
(...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
901 this.mosaicMode_.debugMe(); | 901 this.mosaicMode_.debugMe(); |
902 }; | 902 }; |
903 | 903 |
904 /** | 904 /** |
905 * Singleton gallery. | 905 * Singleton gallery. |
906 * @type {Gallery} | 906 * @type {Gallery} |
907 */ | 907 */ |
908 var gallery = null; | 908 var gallery = null; |
909 | 909 |
910 /** | 910 /** |
911 * Initialize the window. | 911 * Promise to initialize the load time data. |
912 * @param {!BackgroundComponents} backgroundComponents Background components. | 912 * @type {!Promise} |
913 */ | 913 */ |
914 window.initialize = function(backgroundComponents) { | 914 var loadTimeDataPromise = new Promise(function(fulfill, reject) { |
915 window.loadTimeData.data = backgroundComponents.stringData; | 915 chrome.fileManagerPrivate.getStrings(function(strings) { |
916 gallery = new Gallery(backgroundComponents.volumeManager); | 916 window.loadTimeData.data = strings; |
917 }; | 917 i18nTemplate.process(document, loadTimeData); |
| 918 fulfill(true); |
| 919 }); |
| 920 }); |
918 | 921 |
919 /** | 922 /** |
920 * Loads entries. | 923 * Promise to initialize volume manager. |
921 * @param {!Array.<Entry>} selectedEntries Array of selected entries. | 924 * @type {!Promise} |
922 */ | 925 */ |
923 window.loadEntries = function(selectedEntries) { | 926 var volumeManagerPromise = new Promise(function(fulfill, reject) { |
924 gallery.load(selectedEntries); | 927 var volumeManager = new VolumeManagerWrapper( |
925 }; | 928 VolumeManagerWrapper.DriveEnabledStatus.DRIVE_ENABLED); |
| 929 volumeManager.ensureInitialized(fulfill.bind(null, volumeManager)); |
| 930 }); |
| 931 |
| 932 /** |
| 933 * Promise to initialize both the volume manager and the load time data. |
| 934 * @type {!Promise} |
| 935 */ |
| 936 var initializePromise = |
| 937 Promise.all([loadTimeDataPromise, volumeManagerPromise]). |
| 938 then(function(args) { |
| 939 var volumeManager = args[1]; |
| 940 var gallery = new Gallery(volumeManager); |
| 941 return gallery; |
| 942 }); |
| 943 |
| 944 // Loads entries. |
| 945 initializePromise.then( |
| 946 /** |
| 947 * Loads entries. |
| 948 * @param {!Gallery} gallery The gallery instance. |
| 949 */ |
| 950 function(gallery) { |
| 951 util.URLsToEntries(window.appState.urls, function(entries) { |
| 952 gallery.load(entries); |
| 953 }); |
| 954 }); |
926 | 955 |
927 /** | 956 /** |
928 * Enteres the debug mode. | 957 * Enteres the debug mode. |
929 */ | 958 */ |
930 window.debugMe = function() { | 959 window.debugMe = function() { |
931 gallery.debugMe(); | 960 initializePromise.then(function(gallery) { |
| 961 gallery.debugMe(); |
| 962 }); |
932 }; | 963 }; |
OLD | NEW |