Index: ui/file_manager/file_manager/background/js/volume_info_impl.js |
diff --git a/ui/file_manager/file_manager/background/js/volume_info_impl.js b/ui/file_manager/file_manager/background/js/volume_info_impl.js |
index c2904b73c5d8df5fb3d78a5d0f895c860661ea11..615468e1f05d24ff858c6e0d25714c126572cdb7 100644 |
--- a/ui/file_manager/file_manager/background/js/volume_info_impl.js |
+++ b/ui/file_manager/file_manager/background/js/volume_info_impl.js |
@@ -53,6 +53,14 @@ function VolumeInfoImpl( |
this.fileSystem_ = fileSystem; |
this.label_ = label; |
this.displayRoot_ = null; |
+ this.teamDriveDisplayRoot_ = null; |
+ |
+ /** @type {boolean}} */ |
fukino
2017/04/27 10:44:57
Remove the extra '}'.
(I was surprised this passes
yamaguchi
2017/04/28 11:12:15
Done.
|
+ this.isTeamDrivesEnabled_ = false; |
+ |
+ chrome.commandLinePrivate.hasSwitch('team-drives', function(enabled) { |
+ this.isTeamDrivesEnabled_ = enabled; |
+ }.bind(this)); |
/** @type {Object<!FakeEntry>} */ |
this.fakeEntries_ = {}; |
@@ -60,6 +68,9 @@ function VolumeInfoImpl( |
/** @type {Promise.<!DirectoryEntry>} */ |
this.displayRootPromise_ = null; |
+ /** @type {Promise.<!Array<!DirectoryEntry>>} */ |
+ this.driveDisplayRootPromises_ = null; |
+ |
if (volumeType === VolumeManagerCommon.VolumeType.DRIVE) { |
// TODO(mtomasz): Convert fake entries to DirectoryProvider. |
this.fakeEntries_[VolumeManagerCommon.RootType.DRIVE_OFFLINE] = { |
@@ -122,6 +133,14 @@ VolumeInfoImpl.prototype = /** @struct */ { |
return this.displayRoot_; |
}, |
/** |
+ * @return {DirectoryEntry} The display root path of Team Drives directory. |
+ * It is null before finishing to resolve the entry. Valid only for Drive |
+ * volume. |
+ */ |
+ get teamDriveDisplayRoot() { |
+ return this.teamDriveDisplayRoot_; |
+ }, |
+ /** |
* @return {Object<!FakeEntry>} Fake entries. |
*/ |
get fakeEntries() { |
@@ -216,17 +235,36 @@ VolumeInfoImpl.prototype.resolveDisplayRoot = function(opt_onSuccess, |
else |
this.displayRootPromise_ = /** @type {Promise.<!DirectoryEntry>} */ ( |
Promise.reject(this.error)); |
+ this.displayRootPromise_.then(function(displayRoot) { |
+ this.displayRoot_ = displayRoot; |
+ }.bind(this)); |
} else { |
// For Drive, we need to resolve. |
var displayRootURL = this.fileSystem_.root.toURL() + '/root'; |
- this.displayRootPromise_ = new Promise( |
- window.webkitResolveLocalFileSystemURL.bind(null, displayRootURL)); |
+ var displayRootPromise = |
+ new Promise( |
+ window.webkitResolveLocalFileSystemURL.bind(null, displayRootURL)) |
+ .then(function(result) { |
+ this.displayRoot_ = result; |
+ return this.displayRoot_; |
+ }.bind(this), null); |
+ if (!this.isTeamDrivesEnabled_) { |
+ this.displayRootPromise_ = displayRootPromise; |
+ } else { |
+ var teamDrivesDisplayRootURL = this.fileSystem_.root.toURL() + |
+ VolumeManagerCommon.TEAM_DRIVES_DIRECTORY_PATH; |
+ this.driveDisplayRootPromises_ = Promise.all([ |
+ displayRootPromise, |
+ new Promise(window.webkitResolveLocalFileSystemURL.bind( |
+ null, teamDrivesDisplayRootURL)) |
+ ]); |
+ this.displayRootPromise_ = |
+ this.driveDisplayRootPromises_.then(function(result) { |
+ this.teamDriveDisplayRoot_ = result[1]; |
+ return this.displayRoot_; |
+ }.bind(this), opt_onFailure); |
+ } |
} |
- |
- // Store the obtained displayRoot. |
- this.displayRootPromise_.then(function(displayRoot) { |
- this.displayRoot_ = displayRoot; |
- }.bind(this)); |
} |
if (opt_onSuccess) |
this.displayRootPromise_.then(opt_onSuccess, opt_onFailure); |