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 ContentMetadataProvider.WORKER_SCRIPT = '/js/metadata_worker.js'; |
10 | 11 |
11 /** | 12 /** |
12 * Gallery for viewing and editing image files. | 13 * Gallery for viewing and editing image files. |
13 * | 14 * |
14 * @param {!VolumeManager} volumeManager The VolumeManager instance of the | 15 * @param {!VolumeManager} volumeManager The VolumeManager instance of the |
15 * system. | 16 * system. |
16 * @constructor | 17 * @constructor |
17 * @struct | 18 * @struct |
18 */ | 19 */ |
19 function Gallery(volumeManager) { | 20 function Gallery(volumeManager) { |
(...skipping 24 matching lines...) Expand all Loading... |
44 readonlyDirName: '', | 45 readonlyDirName: '', |
45 displayStringFunction: function() { return ''; }, | 46 displayStringFunction: function() { return ''; }, |
46 loadTimeData: {}, | 47 loadTimeData: {}, |
47 curDirEntry: null, | 48 curDirEntry: null, |
48 searchResults: null | 49 searchResults: null |
49 }; | 50 }; |
50 this.container_ = queryRequiredElement(document, '.gallery'); | 51 this.container_ = queryRequiredElement(document, '.gallery'); |
51 this.document_ = document; | 52 this.document_ = document; |
52 this.metadataCache_ = this.context_.metadataCache; | 53 this.metadataCache_ = this.context_.metadataCache; |
53 this.volumeManager_ = volumeManager; | 54 this.volumeManager_ = volumeManager; |
| 55 /** |
| 56 * @private {!FileSystemMetadata} |
| 57 * @const |
| 58 */ |
| 59 this.fileSystemMetadata_ = FileSystemMetadata.create( |
| 60 new MetadataProviderCache(), volumeManager); |
54 this.selectedEntry_ = null; | 61 this.selectedEntry_ = null; |
55 this.metadataCacheObserverId_ = null; | 62 this.metadataCacheObserverId_ = null; |
56 this.onExternallyUnmountedBound_ = this.onExternallyUnmounted_.bind(this); | 63 this.onExternallyUnmountedBound_ = this.onExternallyUnmounted_.bind(this); |
57 | 64 |
58 this.dataModel_ = new GalleryDataModel( | 65 this.dataModel_ = new GalleryDataModel( |
59 this.context_.metadataCache); | 66 this.context_.metadataCache, |
| 67 this.fileSystemMetadata_); |
60 var downloadVolumeInfo = this.volumeManager_.getCurrentProfileVolumeInfo( | 68 var downloadVolumeInfo = this.volumeManager_.getCurrentProfileVolumeInfo( |
61 VolumeManagerCommon.VolumeType.DOWNLOADS); | 69 VolumeManagerCommon.VolumeType.DOWNLOADS); |
62 downloadVolumeInfo.resolveDisplayRoot().then(function(entry) { | 70 downloadVolumeInfo.resolveDisplayRoot().then(function(entry) { |
63 this.dataModel_.fallbackSaveDirectory = entry; | 71 this.dataModel_.fallbackSaveDirectory = entry; |
64 }.bind(this)).catch(function(error) { | 72 }.bind(this)).catch(function(error) { |
65 console.error( | 73 console.error( |
66 'Failed to obtain the fallback directory: ' + (error.stack || error)); | 74 'Failed to obtain the fallback directory: ' + (error.stack || error)); |
67 }); | 75 }); |
68 this.selectionModel_ = new cr.ui.ListSelectionModel(); | 76 this.selectionModel_ = new cr.ui.ListSelectionModel(); |
69 | 77 |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 chunk.forEach(function(chunkItem, index) { | 372 chunk.forEach(function(chunkItem, index) { |
365 var locationInfo = self.volumeManager_.getLocationInfo(chunkItem.entry); | 373 var locationInfo = self.volumeManager_.getLocationInfo(chunkItem.entry); |
366 if (!locationInfo) // Skip the item, since gone. | 374 if (!locationInfo) // Skip the item, since gone. |
367 return; | 375 return; |
368 var clonedMetadata = MetadataCache.cloneMetadata(metadataList[index]); | 376 var clonedMetadata = MetadataCache.cloneMetadata(metadataList[index]); |
369 items.push(new Gallery.Item( | 377 items.push(new Gallery.Item( |
370 chunkItem.entry, | 378 chunkItem.entry, |
371 locationInfo, | 379 locationInfo, |
372 clonedMetadata, | 380 clonedMetadata, |
373 self.metadataCache_, | 381 self.metadataCache_, |
| 382 self.fileSystemMetadata_, |
374 /* original */ true)); | 383 /* original */ true)); |
375 }); | 384 }); |
376 self.dataModel_.push.apply(self.dataModel_, items); | 385 self.dataModel_.push.apply(self.dataModel_, items); |
377 | 386 |
378 // Apply the selection. | 387 // Apply the selection. |
379 var selectionUpdated = false; | 388 var selectionUpdated = false; |
380 for (var i = 0; i < chunk.length; i++) { | 389 for (var i = 0; i < chunk.length; i++) { |
381 if (!chunk[i].selected) | 390 if (!chunk[i].selected) |
382 continue; | 391 continue; |
383 var index = self.dataModel_.indexOf(items[i]); | 392 var index = self.dataModel_.indexOf(items[i]); |
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
954 }); | 963 }); |
955 | 964 |
956 /** | 965 /** |
957 * Enteres the debug mode. | 966 * Enteres the debug mode. |
958 */ | 967 */ |
959 window.debugMe = function() { | 968 window.debugMe = function() { |
960 initializePromise.then(function(gallery) { | 969 initializePromise.then(function(gallery) { |
961 gallery.debugMe(); | 970 gallery.debugMe(); |
962 }); | 971 }); |
963 }; | 972 }; |
OLD | NEW |