Index: chrome/browser/resources/file_manager/js/file_manager.js |
=================================================================== |
--- chrome/browser/resources/file_manager/js/file_manager.js (revision 136864) |
+++ chrome/browser/resources/file_manager/js/file_manager.js (working copy) |
@@ -34,8 +34,6 @@ |
this.commands_ = {}; |
- this.thumbnailUrlCache_ = {}; |
- |
this.document_ = dialogDom.ownerDocument; |
this.dialogType_ = this.params_.type || FileManager.DialogType.FULL_PAGE; |
@@ -317,6 +315,10 @@ |
this.initCommands_(); |
this.metadataCache_ = MetadataCache.createFull(); |
+ // PyAuto tests monitor this state by polling this variable |
+ this.__defineGetter__('workerInitialized_', function() { |
+ return this.metadataCache_.isInitialized(); |
+ }.bind(this)); |
this.shortDateFormatter_ = |
this.locale_.createDateTimeFormat({'dateType': 'medium'}); |
@@ -417,11 +419,6 @@ |
this.metadataProvider_ = |
new MetadataProvider(this.filesystem_.root.toURL()); |
- // PyAuto tests monitor this state by polling this variable |
- this.__defineGetter__('workerInitialized_', function() { |
- return self.getMetadataProvider().isInitialized(); |
- }); |
- |
if (this.dialogType_ == FileManager.DialogType.FULL_PAGE) |
this.initDataTransferOperations_(); |
@@ -1674,11 +1671,6 @@ |
var self = this; |
function onThumbnailURL(iconType, url, transform) { |
- self.thumbnailUrlCache_[entry.fullPath] = { |
- iconType: iconType, |
- url: url, |
- transform: transform |
- }; |
img.onload = function() { |
self.centerImage_(img.style, img.width, img.height, fill); |
if (opt_imageLoadCallback) |
@@ -1695,12 +1687,7 @@ |
util.applyTransform(box, transform); |
} |
- // TODO(dgozman): move to new metadata cache. |
- var cached = this.thumbnailUrlCache_[entry.fullPath]; |
- if (cached) |
- onThumbnailURL(cached.iconType, cached.url, cached.transform); |
- else |
- this.getThumbnailURL(entry, onThumbnailURL); |
+ this.getThumbnailURL(entry, onThumbnailURL); |
return box; |
}; |
@@ -2359,10 +2346,6 @@ |
DirectoryModel.getRootType(path) == DirectoryModel.RootType.GDATA; |
}; |
- FileManager.prototype.getMetadataProvider = function() { |
- return this.metadataProvider_; |
- }; |
- |
/** |
* Callback called when tasks for selected files are determined. |
* @param {Object} selection Selection is passed here, since this.selection |
@@ -2891,7 +2874,7 @@ |
self.directoryModel_.getRootName()) : |
null, |
saveDirEntry: readonly ? downloadsDir : currentDir, |
- metadataProvider: self.getMetadataProvider(), |
+ metadataProvider: self.metadataProvider_, |
getShareActions: self.getShareActions_.bind(self), |
onNameChange: function(name) { |
self.document_.title = gallerySelection = name; |
@@ -3056,24 +3039,30 @@ |
return; |
var iconType = FileType.getIcon(entry); |
+ var metadataCache = this.metadataCache_; |
function returnStockIcon() { |
- callback(iconType, FileType.getPreviewArt(iconType)); |
+ callback(iconType, FileType.getPreviewArt(iconType), ''); |
} |
- var self = this; |
- this.getMetadataProvider().fetch(entry.toURL(), function(metadata) { |
- if (metadata.thumbnailURL) { |
- callback(iconType, metadata.thumbnailURL, |
- metadata.thumbnailTransform); |
+ function tryUsingImageUrl() { |
+ metadataCache.get(entry, 'filesystem|media', function(metadata) { |
+ if (FileType.canUseImageUrlForPreview( |
+ metadata.media.width, |
+ metadata.media.height, |
+ metadata.filesystem.size)) { |
+ callback(iconType, entry.toURL(), metadata.media.imageTransform); |
+ } else { |
+ returnStockIcon(); |
+ } |
+ }); |
+ } |
+ |
+ metadataCache.get(entry, 'thumbnail', function(thumbnail) { |
+ if (thumbnail) { |
+ callback(iconType, thumbnail.url, thumbnail.transform); |
} else if (iconType == 'image') { |
- self.metadataCache_.get(entry, 'filesystem', function(filesystem) { |
- if (FileType.canUseImageUrlForPreview(metadata, filesystem.size)) { |
- callback(iconType, entry.toURL(), metadata.imageTransform); |
- } else { |
- returnStockIcon(); |
- } |
- }); |
+ tryUsingImageUrl(); |
} else { |
returnStockIcon(); |
} |
@@ -3260,17 +3249,6 @@ |
this.updateOkButton_(); |
- var newThumbnailUrlCache = {}; |
- if (this.selection) { |
- var entries = this.selection.entries; |
- for (var i = 0; i < entries.length; i++) { |
- var path = entries[i].fullPath; |
- if (path in this.thumbnailUrlCache_) |
- newThumbnailUrlCache[path] = this.thumbnailUrlCache_[path]; |
- } |
- } |
- this.thumbnailUrlCache_ = newThumbnailUrlCache; |
- |
setTimeout(this.onSelectionChangeComplete_.bind(this, event), 0); |
}; |