Commit 82e69508 authored by mtomasz@chromium.org's avatar mtomasz@chromium.org

Remove fullPaths from the file_grid.js and file_table.js.

This patch removes fullPaths from the file views, by using the volume manager and the getLocationInfo() method instead.

BUG=320967
TEST=Tested manually.

Review URL: https://codereview.chromium.org/130533003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@243881 0039d316-1c4b-4281-b951-d872f2087c98
parent 8a15a6c8
...@@ -35,11 +35,13 @@ FileGrid.prototype.__proto__ = cr.ui.Grid.prototype; ...@@ -35,11 +35,13 @@ FileGrid.prototype.__proto__ = cr.ui.Grid.prototype;
* @param {HTMLElement} self The grid to decorate. * @param {HTMLElement} self The grid to decorate.
* @param {MetadataCache} metadataCache Metadata cache to find entries * @param {MetadataCache} metadataCache Metadata cache to find entries
* metadata. * metadata.
* @param {VolumeManagerWrapper} volumeManager Volume manager instance.
*/ */
FileGrid.decorate = function(self, metadataCache) { FileGrid.decorate = function(self, metadataCache, volumeManager) {
cr.ui.Grid.decorate(self); cr.ui.Grid.decorate(self);
self.__proto__ = FileGrid.prototype; self.__proto__ = FileGrid.prototype;
self.metadataCache_ = metadataCache; self.metadataCache_ = metadataCache;
self.volumeManager_ = volumeManager;
self.scrollBar_ = new MainPanelScrollBar(); self.scrollBar_ = new MainPanelScrollBar();
self.scrollBar_.initialize(self.parentNode, self); self.scrollBar_.initialize(self.parentNode, self);
...@@ -71,6 +73,7 @@ FileGrid.prototype.updateListItemsMetadata = function(type, props) { ...@@ -71,6 +73,7 @@ FileGrid.prototype.updateListItemsMetadata = function(type, props) {
FileGrid.decorateThumbnailBox(box, FileGrid.decorateThumbnailBox(box,
entry, entry,
this.metadataCache_, this.metadataCache_,
this.volumeManager_,
ThumbnailLoader.FillMode.FIT, ThumbnailLoader.FillMode.FIT,
FileGrid.ThumbnailQuality.HIGH); FileGrid.ThumbnailQuality.HIGH);
} }
...@@ -100,8 +103,9 @@ FileGrid.prototype.relayoutImmediately_ = function() { ...@@ -100,8 +103,9 @@ FileGrid.prototype.relayoutImmediately_ = function() {
* @param {HTMLElement} li List item. * @param {HTMLElement} li List item.
* @param {Entry} entry Entry to render a thumbnail for. * @param {Entry} entry Entry to render a thumbnail for.
* @param {MetadataCache} metadataCache To retrieve metadata. * @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'; li.className = 'thumbnail-item';
if (entry) if (entry)
filelist.decorateListItem(li, entry, metadataCache); filelist.decorateListItem(li, entry, metadataCache);
...@@ -115,6 +119,7 @@ FileGrid.decorateThumbnail = function(li, entry, metadataCache) { ...@@ -115,6 +119,7 @@ FileGrid.decorateThumbnail = function(li, entry, metadataCache) {
FileGrid.decorateThumbnailBox(box, FileGrid.decorateThumbnailBox(box,
entry, entry,
metadataCache, metadataCache,
volumeManager,
ThumbnailLoader.FillMode.AUTO, ThumbnailLoader.FillMode.AUTO,
FileGrid.ThumbnailQuality.HIGH); FileGrid.ThumbnailQuality.HIGH);
} }
...@@ -132,13 +137,15 @@ FileGrid.decorateThumbnail = function(li, entry, metadataCache) { ...@@ -132,13 +137,15 @@ FileGrid.decorateThumbnail = function(li, entry, metadataCache) {
* @param {HTMLDivElement} box Box to decorate. * @param {HTMLDivElement} box Box to decorate.
* @param {Entry} entry Entry which thumbnail is generating for. * @param {Entry} entry Entry which thumbnail is generating for.
* @param {MetadataCache} metadataCache To retrieve metadata. * @param {MetadataCache} metadataCache To retrieve metadata.
* @param {VolumeManagerWrapper} volumeManager Volume manager instance.
* @param {ThumbnailLoader.FillMode} fillMode Fill mode. * @param {ThumbnailLoader.FillMode} fillMode Fill mode.
* @param {FileGrid.ThumbnailQuality} quality Thumbnail quality. * @param {FileGrid.ThumbnailQuality} quality Thumbnail quality.
* @param {function(HTMLElement)=} opt_imageLoadCallback Callback called when * @param {function(HTMLElement)=} opt_imageLoadCallback Callback called when
* the image has been loaded before inserting it into the DOM. * the image has been loaded before inserting it into the DOM.
*/ */
FileGrid.decorateThumbnailBox = function( FileGrid.decorateThumbnailBox = function(
box, entry, metadataCache, fillMode, quality, opt_imageLoadCallback) { box, entry, metadataCache, volumeManager, fillMode, quality,
opt_imageLoadCallback) {
box.className = 'img-container'; box.className = 'img-container';
if (entry.isDirectory) { if (entry.isDirectory) {
box.setAttribute('generic-thumbnail', 'folder'); box.setAttribute('generic-thumbnail', 'folder');
...@@ -149,8 +156,8 @@ FileGrid.decorateThumbnailBox = function( ...@@ -149,8 +156,8 @@ FileGrid.decorateThumbnailBox = function(
var metadataTypes = 'thumbnail|filesystem'; var metadataTypes = 'thumbnail|filesystem';
// TODO(mtomasz): Use Entry instead of paths. var locationInfo = volumeManager.getLocationInfo(entry);
if (PathUtil.isDriveBasedPath(entry.fullPath)) { if (locationInfo && locationInfo.isDriveBased) {
metadataTypes += '|drive'; metadataTypes += '|drive';
} else { } else {
// TODO(dgozman): If we ask for 'media' for a Drive file we fall into an // TODO(dgozman): If we ask for 'media' for a Drive file we fall into an
...@@ -168,7 +175,7 @@ FileGrid.decorateThumbnailBox = function( ...@@ -168,7 +175,7 @@ FileGrid.decorateThumbnailBox = function(
break; break;
case FileGrid.ThumbnailQuality.HIGH: case FileGrid.ThumbnailQuality.HIGH:
// TODO(mtomasz): Use Entry instead of paths. // TODO(mtomasz): Use Entry instead of paths.
useEmbedded = PathUtil.isDriveBasedPath(entry.fullPath) ? useEmbedded = (locationInfo && locationInfo.isDriveBased) ?
ThumbnailLoader.UseEmbedded.USE_EMBEDDED : ThumbnailLoader.UseEmbedded.USE_EMBEDDED :
ThumbnailLoader.UseEmbedded.NO_EMBEDDED; ThumbnailLoader.UseEmbedded.NO_EMBEDDED;
break; break;
...@@ -218,7 +225,10 @@ Object.defineProperty(FileGrid.Item.prototype, 'label', { ...@@ -218,7 +225,10 @@ Object.defineProperty(FileGrid.Item.prototype, 'label', {
*/ */
FileGrid.Item.decorate = function(li, entry, grid) { FileGrid.Item.decorate = function(li, entry, grid) {
li.__proto__ = FileGrid.Item.prototype; 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 // Override the default role 'listitem' to 'option' to match the parent's
// role (listbox). // role (listbox).
......
...@@ -732,7 +732,7 @@ var BOTTOM_MARGIN_FOR_PREVIEW_PANEL_PX = 52; ...@@ -732,7 +732,7 @@ var BOTTOM_MARGIN_FOR_PREVIEW_PANEL_PX = 52;
var fullPage = this.dialogType == DialogType.FULL_PAGE; var fullPage = this.dialogType == DialogType.FULL_PAGE;
FileTable.decorate(this.table_, this.metadataCache_, fullPage); FileTable.decorate(this.table_, this.metadataCache_, fullPage);
FileGrid.decorate(this.grid_, this.metadataCache_); FileGrid.decorate(this.grid_, this.metadataCache_, this.volumeManager_);
this.previewPanel_ = new PreviewPanel( this.previewPanel_ = new PreviewPanel(
dom.querySelector('.preview-panel'), dom.querySelector('.preview-panel'),
......
...@@ -957,14 +957,12 @@ filelist.decorateSelectionCheckbox = function(input, entry, list) { ...@@ -957,14 +957,12 @@ filelist.decorateSelectionCheckbox = function(input, entry, list) {
*/ */
filelist.decorateListItem = function(li, entry, metadataCache) { filelist.decorateListItem = function(li, entry, metadataCache) {
li.classList.add(entry.isDirectory ? 'directory' : 'file'); li.classList.add(entry.isDirectory ? 'directory' : 'file');
// TODO(mtomasz): Use Entry instead of paths. // The metadata may not yet be ready. In that case, the list item will be
if (PathUtil.isDriveBasedPath(entry.fullPath)) { // updated when the metadata is ready via updateListItemsMetadata. For files
// The metadata may not yet be ready. In that case, the list item will be // not on Drive, driveProps is not available.
// updated when the metadata is ready via updateListItemsMetadata. var driveProps = metadataCache.getCached(entry, 'drive');
var driveProps = metadataCache.getCached(entry, 'drive'); if (driveProps)
if (driveProps) filelist.updateListItemDriveProps(li, driveProps);
filelist.updateListItemDriveProps(li, driveProps);
}
// Overriding the default role 'list' to 'listbox' for better // Overriding the default role 'list' to 'listbox' for better
// accessibility on ChromeOS. // accessibility on ChromeOS.
......
...@@ -58,7 +58,9 @@ var PreviewPanel = function(element, ...@@ -58,7 +58,9 @@ var PreviewPanel = function(element,
* @type {PreviewPanel.Thumbnails} * @type {PreviewPanel.Thumbnails}
*/ */
this.thumbnails = new PreviewPanel.Thumbnails( this.thumbnails = new PreviewPanel.Thumbnails(
element.querySelector('.preview-thumbnails'), metadataCache); element.querySelector('.preview-thumbnails'),
metadataCache,
volumeManager);
/** /**
* @type {HTMLElement} * @type {HTMLElement}
...@@ -95,7 +97,7 @@ var PreviewPanel = function(element, ...@@ -95,7 +97,7 @@ var PreviewPanel = function(element,
this.sequence_ = 0; this.sequence_ = 0;
/** /**
* @type {VolumeManager} * @type {VolumeManagerWrapper}
* @private * @private
*/ */
this.volumeManager_ = volumeManager; this.volumeManager_ = volumeManager;
...@@ -375,11 +377,13 @@ PreviewPanel.CalculatingSizeLabel.prototype.onStep_ = function() { ...@@ -375,11 +377,13 @@ PreviewPanel.CalculatingSizeLabel.prototype.onStep_ = function() {
* *
* @param {HTMLElement} element DOM Element of thumbnail container. * @param {HTMLElement} element DOM Element of thumbnail container.
* @param {MetadataCache} metadataCache MetadataCache. * @param {MetadataCache} metadataCache MetadataCache.
* @param {VolumeManagerWrapper} volumeManager Volume manager instance.
* @constructor * @constructor
*/ */
PreviewPanel.Thumbnails = function(element, metadataCache) { PreviewPanel.Thumbnails = function(element, metadataCache, volumeManager) {
this.element_ = element; this.element_ = element;
this.metadataCache_ = metadataCache; this.metadataCache_ = metadataCache;
this.volumeManager_ = volumeManager;
this.sequence_ = 0; this.sequence_ = 0;
Object.seal(this); Object.seal(this);
}; };
...@@ -437,6 +441,7 @@ PreviewPanel.Thumbnails.prototype.loadThumbnails_ = function(selection) { ...@@ -437,6 +441,7 @@ PreviewPanel.Thumbnails.prototype.loadThumbnails_ = function(selection) {
FileGrid.decorateThumbnailBox(box, FileGrid.decorateThumbnailBox(box,
entries[i], entries[i],
this.metadataCache_, this.metadataCache_,
this.volumeManager_,
ThumbnailLoader.FillMode.FILL, ThumbnailLoader.FillMode.FILL,
FileGrid.ThumbnailQuality.LOW, FileGrid.ThumbnailQuality.LOW,
i == 0 && length == 1 && i == 0 && length == 1 &&
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment