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

Provide the alternate URL as the drag and drop URL for hosted docs.

With the old Drive integration, all files were accessed via
externalfile: URLs. Those for hosted docs redirected to the actual URL
for accessing that doc. With DriveFS, real file: URLs are used so no
externalfile: URLs exist. The drag and drop code populates the File and,
if available, the externalfile: URL in the DataTransfer. For hosted docs
under DriveFS, this is insufficient as the files are not openable.
However, the alternateUrl is the URL needed to access the hosted doc so
substitute it for the externalfile: URL for hosted docs.

Bug: 913725
Change-Id: Ib9456042e1e864b378b71db404e1ea406959b1fe
Reviewed-on: https://chromium-review.googlesource.com/c/1370152Reviewed-by: default avatarLuciano Pacheco <lucmult@chromium.org>
Commit-Queue: Sam McNally <sammc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#615428}
parent 55111f45
...@@ -1653,16 +1653,22 @@ FileTransferController.prototype.onFileSelectionChangedThrottled_ = function() { ...@@ -1653,16 +1653,22 @@ FileTransferController.prototype.onFileSelectionChangedThrottled_ = function() {
this.preloadThumbnailImage_(entries[0]); this.preloadThumbnailImage_(entries[0]);
} }
this.metadataModel_.get(entries, ['externalFileUrl']).then( this.metadataModel_
function(metadataList) { .get(entries, ['alternateUrl', 'externalFileUrl', 'hosted'])
.then(function(metadataList) {
// |Copy| is the only menu item affected by allDriveFilesAvailable_. // |Copy| is the only menu item affected by allDriveFilesAvailable_.
// It could be open right now, update its UI. // It could be open right now, update its UI.
this.copyCommand_.disabled = this.copyCommand_.disabled =
!this.canCutOrCopy_(false /* not move operation */); !this.canCutOrCopy_(false /* not move operation */);
for (var i = 0; i < entries.length; i++) { for (var i = 0; i < entries.length; i++) {
if (entries[i].isFile) { if (entries[i].isFile) {
asyncData[entries[i].toURL()].externalFileUrl = if (metadataList[i].hosted) {
metadataList[i].externalFileUrl; asyncData[entries[i].toURL()].externalFileUrl =
metadataList[i].alternateUrl;
} else {
asyncData[entries[i].toURL()].externalFileUrl =
metadataList[i].externalFileUrl;
}
} }
} }
}.bind(this)); }.bind(this));
......
...@@ -18,6 +18,7 @@ function ExternalMetadataProvider() { ...@@ -18,6 +18,7 @@ function ExternalMetadataProvider() {
* @const {!Array<string>} * @const {!Array<string>}
*/ */
ExternalMetadataProvider.PROPERTY_NAMES = [ ExternalMetadataProvider.PROPERTY_NAMES = [
'alternateUrl',
'availableOffline', 'availableOffline',
'availableWhenMetered', 'availableWhenMetered',
'contentMimeType', 'contentMimeType',
...@@ -90,6 +91,8 @@ ExternalMetadataProvider.prototype.convertResults_ = ...@@ -90,6 +91,8 @@ ExternalMetadataProvider.prototype.convertResults_ =
for (var i = 0; i < propertiesList.length; i++) { for (var i = 0; i < propertiesList.length; i++) {
var prop = propertiesList[i]; var prop = propertiesList[i];
var item = new MetadataItem(); var item = new MetadataItem();
if (prop.alternateUrl !== undefined || nameMap['alternateUrl'])
item.alternateUrl = prop.alternateUrl;
if (prop.availableOffline !== undefined || nameMap['availableOffline']) if (prop.availableOffline !== undefined || nameMap['availableOffline'])
item.availableOffline = prop.availableOffline; item.availableOffline = prop.availableOffline;
if (prop.availableWhenMetered !== undefined || if (prop.availableWhenMetered !== undefined ||
......
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