Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * Represents each volume, such as "drive", "download directory", each "USB | 6 * Represents each volume, such as "drive", "download directory", each "USB |
| 7 * flush storage", or "mounted zip archive" etc. | 7 * flush storage", or "mounted zip archive" etc. |
| 8 * | 8 * |
| 9 * @constructor | 9 * @constructor |
| 10 * @implements {VolumeInfo} | 10 * @implements {VolumeInfo} |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 46 extensionId, | 46 extensionId, |
| 47 hasMedia, | 47 hasMedia, |
| 48 configurable, | 48 configurable, |
| 49 watchable, | 49 watchable, |
| 50 source) { | 50 source) { |
| 51 this.volumeType_ = volumeType; | 51 this.volumeType_ = volumeType; |
| 52 this.volumeId_ = volumeId; | 52 this.volumeId_ = volumeId; |
| 53 this.fileSystem_ = fileSystem; | 53 this.fileSystem_ = fileSystem; |
| 54 this.label_ = label; | 54 this.label_ = label; |
| 55 this.displayRoot_ = null; | 55 this.displayRoot_ = null; |
| 56 this.teamDriveDisplayRoot_ = null; | |
| 57 | |
| 58 /** @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.
| |
| 59 this.isTeamDrivesEnabled_ = false; | |
| 60 | |
| 61 chrome.commandLinePrivate.hasSwitch('team-drives', function(enabled) { | |
| 62 this.isTeamDrivesEnabled_ = enabled; | |
| 63 }.bind(this)); | |
| 56 | 64 |
| 57 /** @type {Object<!FakeEntry>} */ | 65 /** @type {Object<!FakeEntry>} */ |
| 58 this.fakeEntries_ = {}; | 66 this.fakeEntries_ = {}; |
| 59 | 67 |
| 60 /** @type {Promise.<!DirectoryEntry>} */ | 68 /** @type {Promise.<!DirectoryEntry>} */ |
| 61 this.displayRootPromise_ = null; | 69 this.displayRootPromise_ = null; |
| 62 | 70 |
| 71 /** @type {Promise.<!Array<!DirectoryEntry>>} */ | |
| 72 this.driveDisplayRootPromises_ = null; | |
| 73 | |
| 63 if (volumeType === VolumeManagerCommon.VolumeType.DRIVE) { | 74 if (volumeType === VolumeManagerCommon.VolumeType.DRIVE) { |
| 64 // TODO(mtomasz): Convert fake entries to DirectoryProvider. | 75 // TODO(mtomasz): Convert fake entries to DirectoryProvider. |
| 65 this.fakeEntries_[VolumeManagerCommon.RootType.DRIVE_OFFLINE] = { | 76 this.fakeEntries_[VolumeManagerCommon.RootType.DRIVE_OFFLINE] = { |
| 66 isDirectory: true, | 77 isDirectory: true, |
| 67 rootType: VolumeManagerCommon.RootType.DRIVE_OFFLINE, | 78 rootType: VolumeManagerCommon.RootType.DRIVE_OFFLINE, |
| 68 toURL: function() { return 'fake-entry://drive_offline'; } | 79 toURL: function() { return 'fake-entry://drive_offline'; } |
| 69 }; | 80 }; |
| 70 this.fakeEntries_[VolumeManagerCommon.RootType.DRIVE_SHARED_WITH_ME] = { | 81 this.fakeEntries_[VolumeManagerCommon.RootType.DRIVE_SHARED_WITH_ME] = { |
| 71 isDirectory: true, | 82 isDirectory: true, |
| 72 rootType: VolumeManagerCommon.RootType.DRIVE_SHARED_WITH_ME, | 83 rootType: VolumeManagerCommon.RootType.DRIVE_SHARED_WITH_ME, |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 115 return this.fileSystem_; | 126 return this.fileSystem_; |
| 116 }, | 127 }, |
| 117 /** | 128 /** |
| 118 * @return {DirectoryEntry} Display root path. It is null before finishing to | 129 * @return {DirectoryEntry} Display root path. It is null before finishing to |
| 119 * resolve the entry. | 130 * resolve the entry. |
| 120 */ | 131 */ |
| 121 get displayRoot() { | 132 get displayRoot() { |
| 122 return this.displayRoot_; | 133 return this.displayRoot_; |
| 123 }, | 134 }, |
| 124 /** | 135 /** |
| 136 * @return {DirectoryEntry} The display root path of Team Drives directory. | |
| 137 * It is null before finishing to resolve the entry. Valid only for Drive | |
| 138 * volume. | |
| 139 */ | |
| 140 get teamDriveDisplayRoot() { | |
| 141 return this.teamDriveDisplayRoot_; | |
| 142 }, | |
| 143 /** | |
| 125 * @return {Object<!FakeEntry>} Fake entries. | 144 * @return {Object<!FakeEntry>} Fake entries. |
| 126 */ | 145 */ |
| 127 get fakeEntries() { | 146 get fakeEntries() { |
| 128 return this.fakeEntries_; | 147 return this.fakeEntries_; |
| 129 }, | 148 }, |
| 130 /** | 149 /** |
| 131 * @return {(string|undefined)} Error identifier. | 150 * @return {(string|undefined)} Error identifier. |
| 132 */ | 151 */ |
| 133 get error() { | 152 get error() { |
| 134 return this.error_; | 153 return this.error_; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 209 if (!this.displayRootPromise_) { | 228 if (!this.displayRootPromise_) { |
| 210 // TODO(mtomasz): Do not add VolumeInfo which failed to resolve root, and | 229 // TODO(mtomasz): Do not add VolumeInfo which failed to resolve root, and |
| 211 // remove this if logic. Call opt_onSuccess() always, instead. | 230 // remove this if logic. Call opt_onSuccess() always, instead. |
| 212 if (this.volumeType !== VolumeManagerCommon.VolumeType.DRIVE) { | 231 if (this.volumeType !== VolumeManagerCommon.VolumeType.DRIVE) { |
| 213 if (this.fileSystem_) | 232 if (this.fileSystem_) |
| 214 this.displayRootPromise_ = /** @type {Promise.<!DirectoryEntry>} */ ( | 233 this.displayRootPromise_ = /** @type {Promise.<!DirectoryEntry>} */ ( |
| 215 Promise.resolve(this.fileSystem_.root)); | 234 Promise.resolve(this.fileSystem_.root)); |
| 216 else | 235 else |
| 217 this.displayRootPromise_ = /** @type {Promise.<!DirectoryEntry>} */ ( | 236 this.displayRootPromise_ = /** @type {Promise.<!DirectoryEntry>} */ ( |
| 218 Promise.reject(this.error)); | 237 Promise.reject(this.error)); |
| 238 this.displayRootPromise_.then(function(displayRoot) { | |
| 239 this.displayRoot_ = displayRoot; | |
| 240 }.bind(this)); | |
| 219 } else { | 241 } else { |
| 220 // For Drive, we need to resolve. | 242 // For Drive, we need to resolve. |
| 221 var displayRootURL = this.fileSystem_.root.toURL() + '/root'; | 243 var displayRootURL = this.fileSystem_.root.toURL() + '/root'; |
| 222 this.displayRootPromise_ = new Promise( | 244 var displayRootPromise = |
| 223 window.webkitResolveLocalFileSystemURL.bind(null, displayRootURL)); | 245 new Promise( |
| 246 window.webkitResolveLocalFileSystemURL.bind(null, displayRootURL)) | |
| 247 .then(function(result) { | |
| 248 this.displayRoot_ = result; | |
| 249 return this.displayRoot_; | |
| 250 }.bind(this), null); | |
| 251 if (!this.isTeamDrivesEnabled_) { | |
| 252 this.displayRootPromise_ = displayRootPromise; | |
| 253 } else { | |
| 254 var teamDrivesDisplayRootURL = this.fileSystem_.root.toURL() + | |
| 255 VolumeManagerCommon.TEAM_DRIVES_DIRECTORY_PATH; | |
| 256 this.driveDisplayRootPromises_ = Promise.all([ | |
| 257 displayRootPromise, | |
| 258 new Promise(window.webkitResolveLocalFileSystemURL.bind( | |
| 259 null, teamDrivesDisplayRootURL)) | |
| 260 ]); | |
| 261 this.displayRootPromise_ = | |
| 262 this.driveDisplayRootPromises_.then(function(result) { | |
| 263 this.teamDriveDisplayRoot_ = result[1]; | |
| 264 return this.displayRoot_; | |
| 265 }.bind(this), opt_onFailure); | |
| 266 } | |
| 224 } | 267 } |
| 225 | |
| 226 // Store the obtained displayRoot. | |
| 227 this.displayRootPromise_.then(function(displayRoot) { | |
| 228 this.displayRoot_ = displayRoot; | |
| 229 }.bind(this)); | |
| 230 } | 268 } |
| 231 if (opt_onSuccess) | 269 if (opt_onSuccess) |
| 232 this.displayRootPromise_.then(opt_onSuccess, opt_onFailure); | 270 this.displayRootPromise_.then(opt_onSuccess, opt_onFailure); |
| 233 return this.displayRootPromise_; | 271 return this.displayRootPromise_; |
| 234 }; | 272 }; |
| OLD | NEW |