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 ContentMetadataProvider.WORKER_SCRIPT = '/js/metadata_worker.js'; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 displayStringFunction: function() { return ''; }, | 46 displayStringFunction: function() { return ''; }, |
47 loadTimeData: {}, | 47 loadTimeData: {}, |
48 curDirEntry: null, | 48 curDirEntry: null, |
49 searchResults: null | 49 searchResults: null |
50 }; | 50 }; |
51 this.container_ = queryRequiredElement(document, '.gallery'); | 51 this.container_ = queryRequiredElement(document, '.gallery'); |
52 this.document_ = document; | 52 this.document_ = document; |
53 this.metadataCache_ = this.context_.metadataCache; | 53 this.metadataCache_ = this.context_.metadataCache; |
54 this.volumeManager_ = volumeManager; | 54 this.volumeManager_ = volumeManager; |
55 /** | 55 /** |
56 * @private {!FileSystemMetadata} | 56 * @private {!MetadataModel} |
57 * @const | 57 * @const |
58 */ | 58 */ |
59 this.fileSystemMetadata_ = new FileSystemMetadata(volumeManager); | 59 this.metadataModel_ = MetadataModel.create(volumeManager); |
60 this.selectedEntry_ = null; | 60 this.selectedEntry_ = null; |
61 this.metadataCacheObserverId_ = null; | 61 this.metadataCacheObserverId_ = null; |
62 this.onExternallyUnmountedBound_ = this.onExternallyUnmounted_.bind(this); | 62 this.onExternallyUnmountedBound_ = this.onExternallyUnmounted_.bind(this); |
63 this.initialized_ = false; | 63 this.initialized_ = false; |
64 | 64 |
65 this.dataModel_ = new GalleryDataModel( | 65 this.dataModel_ = new GalleryDataModel( |
66 this.context_.metadataCache, | 66 this.context_.metadataCache, |
67 this.fileSystemMetadata_); | 67 this.metadataModel_); |
68 var downloadVolumeInfo = this.volumeManager_.getCurrentProfileVolumeInfo( | 68 var downloadVolumeInfo = this.volumeManager_.getCurrentProfileVolumeInfo( |
69 VolumeManagerCommon.VolumeType.DOWNLOADS); | 69 VolumeManagerCommon.VolumeType.DOWNLOADS); |
70 downloadVolumeInfo.resolveDisplayRoot().then(function(entry) { | 70 downloadVolumeInfo.resolveDisplayRoot().then(function(entry) { |
71 this.dataModel_.fallbackSaveDirectory = entry; | 71 this.dataModel_.fallbackSaveDirectory = entry; |
72 }.bind(this)).catch(function(error) { | 72 }.bind(this)).catch(function(error) { |
73 console.error( | 73 console.error( |
74 'Failed to obtain the fallback directory: ' + (error.stack || error)); | 74 'Failed to obtain the fallback directory: ' + (error.stack || error)); |
75 }); | 75 }); |
76 this.selectionModel_ = new cr.ui.ListSelectionModel(); | 76 this.selectionModel_ = new cr.ui.ListSelectionModel(); |
77 | 77 |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 chunk.forEach(function(chunkItem, index) { | 385 chunk.forEach(function(chunkItem, index) { |
386 var locationInfo = self.volumeManager_.getLocationInfo(chunkItem.entry); | 386 var locationInfo = self.volumeManager_.getLocationInfo(chunkItem.entry); |
387 if (!locationInfo) // Skip the item, since gone. | 387 if (!locationInfo) // Skip the item, since gone. |
388 return; | 388 return; |
389 var clonedMetadata = MetadataCache.cloneMetadata(metadataList[index]); | 389 var clonedMetadata = MetadataCache.cloneMetadata(metadataList[index]); |
390 items.push(new Gallery.Item( | 390 items.push(new Gallery.Item( |
391 chunkItem.entry, | 391 chunkItem.entry, |
392 locationInfo, | 392 locationInfo, |
393 clonedMetadata, | 393 clonedMetadata, |
394 self.metadataCache_, | 394 self.metadataCache_, |
395 self.fileSystemMetadata_, | 395 self.metadataModel_, |
396 /* original */ true)); | 396 /* original */ true)); |
397 }); | 397 }); |
398 self.dataModel_.push.apply(self.dataModel_, items); | 398 self.dataModel_.push.apply(self.dataModel_, items); |
399 | 399 |
400 // Apply the selection. | 400 // Apply the selection. |
401 var selectionUpdated = false; | 401 var selectionUpdated = false; |
402 for (var i = 0; i < chunk.length; i++) { | 402 for (var i = 0; i < chunk.length; i++) { |
403 if (!chunk[i].selected) | 403 if (!chunk[i].selected) |
404 continue; | 404 continue; |
405 var index = self.dataModel_.indexOf(items[i]); | 405 var index = self.dataModel_.indexOf(items[i]); |
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
978 initializePromise.then(reload); | 978 initializePromise.then(reload); |
979 | 979 |
980 /** | 980 /** |
981 * Enteres the debug mode. | 981 * Enteres the debug mode. |
982 */ | 982 */ |
983 window.debugMe = function() { | 983 window.debugMe = function() { |
984 initializePromise.then(function() { | 984 initializePromise.then(function() { |
985 gallery.debugMe(); | 985 gallery.debugMe(); |
986 }); | 986 }); |
987 }; | 987 }; |
OLD | NEW |