Index: chrome/browser/resources/file_manager/foreground/js/file_grid.js |
diff --git a/chrome/browser/resources/file_manager/foreground/js/file_grid.js b/chrome/browser/resources/file_manager/foreground/js/file_grid.js |
index 654b665dca06babe4b4ac3e7e13409c99107d6eb..ba8644ac5a010a66d3ebfc8f750095be4651044f 100644 |
--- a/chrome/browser/resources/file_manager/foreground/js/file_grid.js |
+++ b/chrome/browser/resources/file_manager/foreground/js/file_grid.js |
@@ -35,11 +35,13 @@ FileGrid.prototype.__proto__ = cr.ui.Grid.prototype; |
* @param {HTMLElement} self The grid to decorate. |
* @param {MetadataCache} metadataCache Metadata cache to find entries |
* metadata. |
+ * @param {VolumeManagerWrapper} volumeManager Volume manager instance. |
*/ |
-FileGrid.decorate = function(self, metadataCache) { |
+FileGrid.decorate = function(self, metadataCache, volumeManager) { |
cr.ui.Grid.decorate(self); |
self.__proto__ = FileGrid.prototype; |
self.metadataCache_ = metadataCache; |
+ self.volumeManager_ = volumeManager; |
self.scrollBar_ = new MainPanelScrollBar(); |
self.scrollBar_.initialize(self.parentNode, self); |
@@ -71,6 +73,7 @@ FileGrid.prototype.updateListItemsMetadata = function(type, props) { |
FileGrid.decorateThumbnailBox(box, |
entry, |
this.metadataCache_, |
+ this.volumeManager_, |
ThumbnailLoader.FillMode.FIT, |
FileGrid.ThumbnailQuality.HIGH); |
} |
@@ -100,8 +103,9 @@ FileGrid.prototype.relayoutImmediately_ = function() { |
* @param {HTMLElement} li List item. |
* @param {Entry} entry Entry to render a thumbnail for. |
* @param {MetadataCache} metadataCache To retrieve metadata. |
+ * @param {VolumeManagerWrapper} volumeManager Volume manager instance. |
*/ |
-FileGrid.decorateThumbnail = function(li, entry, metadataCache) { |
+FileGrid.decorateThumbnail = function(li, entry, metadataCache, volumeManager) { |
li.className = 'thumbnail-item'; |
if (entry) |
filelist.decorateListItem(li, entry, metadataCache); |
@@ -115,6 +119,7 @@ FileGrid.decorateThumbnail = function(li, entry, metadataCache) { |
FileGrid.decorateThumbnailBox(box, |
entry, |
metadataCache, |
+ volumeManager, |
ThumbnailLoader.FillMode.AUTO, |
FileGrid.ThumbnailQuality.HIGH); |
} |
@@ -132,13 +137,15 @@ FileGrid.decorateThumbnail = function(li, entry, metadataCache) { |
* @param {HTMLDivElement} box Box to decorate. |
* @param {Entry} entry Entry which thumbnail is generating for. |
* @param {MetadataCache} metadataCache To retrieve metadata. |
+ * @param {VolumeManagerWrapper} volumeManager Volume manager instance. |
* @param {ThumbnailLoader.FillMode} fillMode Fill mode. |
* @param {FileGrid.ThumbnailQuality} quality Thumbnail quality. |
* @param {function(HTMLElement)=} opt_imageLoadCallback Callback called when |
* the image has been loaded before inserting it into the DOM. |
*/ |
FileGrid.decorateThumbnailBox = function( |
- box, entry, metadataCache, fillMode, quality, opt_imageLoadCallback) { |
+ box, entry, metadataCache, volumeManager, fillMode, quality, |
+ opt_imageLoadCallback) { |
box.className = 'img-container'; |
if (entry.isDirectory) { |
box.setAttribute('generic-thumbnail', 'folder'); |
@@ -149,8 +156,8 @@ FileGrid.decorateThumbnailBox = function( |
var metadataTypes = 'thumbnail|filesystem'; |
- // TODO(mtomasz): Use Entry instead of paths. |
- if (PathUtil.isDriveBasedPath(entry.fullPath)) { |
+ var locationInfo = volumeManager.getLocationInfo(entry); |
+ if (locationInfo && locationInfo.isDriveBased) { |
metadataTypes += '|drive'; |
} else { |
// TODO(dgozman): If we ask for 'media' for a Drive file we fall into an |
@@ -168,7 +175,7 @@ FileGrid.decorateThumbnailBox = function( |
break; |
case FileGrid.ThumbnailQuality.HIGH: |
// TODO(mtomasz): Use Entry instead of paths. |
- useEmbedded = PathUtil.isDriveBasedPath(entry.fullPath) ? |
+ useEmbedded = (locationInfo && locationInfo.isDriveBased) ? |
ThumbnailLoader.UseEmbedded.USE_EMBEDDED : |
ThumbnailLoader.UseEmbedded.NO_EMBEDDED; |
break; |
@@ -218,7 +225,10 @@ Object.defineProperty(FileGrid.Item.prototype, 'label', { |
*/ |
FileGrid.Item.decorate = function(li, entry, grid) { |
li.__proto__ = FileGrid.Item.prototype; |
- FileGrid.decorateThumbnail(li, entry, grid.metadataCache_, true); |
+ // TODO(mtomasz): Pass the metadata cache and the volume manager directly |
+ // instead of accessing private members of grid. |
+ FileGrid.decorateThumbnail( |
+ li, entry, grid.metadataCache_, grid.volumeManager_, true); |
// Override the default role 'listitem' to 'option' to match the parent's |
// role (listbox). |