Commit b5b7717b authored by Sam McNally's avatar Sam McNally Committed by Commit Bot

Use file metadata from DriveFS in quickview when available.

MetadataBoxController uses the availability of externalFileUrl in file
metadata to decide whether to obtain metadata via
ExternalMetadataProvider or by reading the file. With DriveFS,
externalFileUrl is not set but ExternalMetadataProvider should be used
for fetching metadata. Also use alternateUrl (which is only set for
Drive files) to detect files where this metadata provider should be
used.

Also skip FSP metadata requests when none of the metadata fields are
available via the FSP API.

Bug: 913738, 587231
Change-Id: I95636e6bcf1d21cea3366d17363ab6300b1d59f8
Reviewed-on: https://chromium-review.googlesource.com/c/1370154
Commit-Queue: Sam McNally <sammc@chromium.org>
Reviewed-by: default avatarLuciano Pacheco <lucmult@chromium.org>
Cr-Commit-Position: refs/heads/master@{#615437}
parent f592cd17
......@@ -498,6 +498,10 @@ class SingleEntryPropertiesGetterForFileSystemProvider {
names_.end()) {
field_mask |= ProvidedFileSystemInterface::METADATA_FIELD_THUMBNAIL;
}
if (!field_mask) {
OnGetMetadataCompleted(nullptr, base::File::FILE_OK);
return;
}
parser.file_system()->GetMetadata(
parser.file_path(), field_mask,
......
......@@ -109,7 +109,7 @@ MetadataBoxController.prototype.updateView_ = function() {
return;
this.metadataModel_
.get([entry], MetadataBoxController.GENERAL_METADATA_NAME.concat([
'hosted', 'externalFileUrl'
'alternateUrl', 'externalFileUrl', 'hosted'
]))
.then(this.onGeneralMetadataLoaded_.bind(this, entry, isSameEntry));
};
......@@ -144,7 +144,7 @@ MetadataBoxController.prototype.onGeneralMetadataLoaded_ = function(
this.fileMetadataFormatter_.formatModDate(item.modificationTime);
}
if (item.externalFileUrl) {
if (item.externalFileUrl || item.alternateUrl) {
this.metadataModel_.get([entry], ['contentMimeType']).then(function(items) {
var item = items[0];
this.metadataBox_.mediaMimeType = item.contentMimeType;
......@@ -157,7 +157,7 @@ MetadataBoxController.prototype.onGeneralMetadataLoaded_ = function(
}
if (['image', 'video', 'audio'].includes(type)) {
if (item.externalFileUrl) {
if (item.externalFileUrl || item.alternateUrl) {
this.metadataModel_.get([entry], ['imageHeight', 'imageWidth'])
.then(function(items) {
var item = items[0];
......
......@@ -109,6 +109,19 @@ testcase.openQuickViewDrive = async function() {
// Open the file in Quick View.
await openQuickView(appId, ENTRIES.hello.nameText);
// Check that the correct mime type is displayed.
const mimeTypeSelector = [
'#quick-view',
'#metadata-box',
// TODO(crbug.com/677338): Replace the attribute selector with key="Type"
// once the key is populated with polymer2 enabled.
'files-metadata-entry[i18n-values="key:METADATA_BOX_MEDIA_MIME_TYPE"]',
'#value div',
];
chrome.test.assertEq(
'text/plain',
(await remoteCall.waitForElement(appId, mimeTypeSelector)).text);
};
/**
......
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