| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 * Thin wrapper for VolumeManager. This should be an interface proxy to talk | 6 * Thin wrapper for VolumeManager. This should be an interface proxy to talk |
| 7 * to VolumeManager. This class also filters Drive related data/events if | 7 * to VolumeManager. This class also filters Drive related data/events if |
| 8 * driveEnabled is set to false. | 8 * driveEnabled is set to false. |
| 9 * | 9 * |
| 10 * @param {VolumeManagerWrapper.DriveEnabledStatus} driveEnabled DRIVE_ENABLED | 10 * @param {VolumeManagerWrapper.DriveEnabledStatus} driveEnabled DRIVE_ENABLED |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 }.bind(this)); | 252 }.bind(this)); |
| 253 }; | 253 }; |
| 254 | 254 |
| 255 /** | 255 /** |
| 256 * Obtains location information from an entry. | 256 * Obtains location information from an entry. |
| 257 * | 257 * |
| 258 * @param {Entry} entry File or directory entry. | 258 * @param {Entry} entry File or directory entry. |
| 259 * @return {EntryLocation} Location information. | 259 * @return {EntryLocation} Location information. |
| 260 */ | 260 */ |
| 261 VolumeManagerWrapper.prototype.getLocationInfo = function(entry) { | 261 VolumeManagerWrapper.prototype.getLocationInfo = function(entry) { |
| 262 return this.volumeManager_ && this.volumeManager_.getLocationInfo(entry); | 262 var locationInfo = |
| 263 this.volumeManager_ && this.volumeManager_.getLocationInfo(entry); |
| 264 if (!locationInfo) |
| 265 return null; |
| 266 if (!this.filterDisabledDriveVolume_(locationInfo.volumeInfo)) |
| 267 return null; |
| 268 return locationInfo; |
| 263 }; | 269 }; |
| 264 | 270 |
| 265 /** | 271 /** |
| 266 * Requests to mount the archive file. | 272 * Requests to mount the archive file. |
| 267 * @param {string} fileUrl The path to the archive file to be mounted. | 273 * @param {string} fileUrl The path to the archive file to be mounted. |
| 268 * @param {function(string)} successCallback Called with mount path on success. | 274 * @param {function(string)} successCallback Called with mount path on success. |
| 269 * @param {function(util.VolumeError)} errorCallback Called when an error | 275 * @param {function(util.VolumeError)} errorCallback Called when an error |
| 270 * occurs. | 276 * occurs. |
| 271 */ | 277 */ |
| 272 VolumeManagerWrapper.prototype.mountArchive = function( | 278 VolumeManagerWrapper.prototype.mountArchive = function( |
| (...skipping 20 matching lines...) Expand all Loading... |
| 293 if (this.pendingTasks_) { | 299 if (this.pendingTasks_) { |
| 294 this.pendingTasks_.push( | 300 this.pendingTasks_.push( |
| 295 this.unmount.bind(this, volumeInfo, successCallback, errorCallback)); | 301 this.unmount.bind(this, volumeInfo, successCallback, errorCallback)); |
| 296 return; | 302 return; |
| 297 } | 303 } |
| 298 | 304 |
| 299 this.volumeManager_.unmount(volumeInfo, successCallback, errorCallback); | 305 this.volumeManager_.unmount(volumeInfo, successCallback, errorCallback); |
| 300 }; | 306 }; |
| 301 | 307 |
| 302 /** | 308 /** |
| 303 * Resolves the absolute path to an entry instance. | |
| 304 * @param {string} path The path to be resolved. | |
| 305 * @param {function(Entry)} successCallback Called with the resolved entry | |
| 306 * on success. | |
| 307 * @param {function(FileError)} errorCallback Called with the error on error. | |
| 308 */ | |
| 309 VolumeManagerWrapper.prototype.resolveAbsolutePath = function( | |
| 310 path, successCallback, errorCallback) { | |
| 311 if (this.pendingTasks_) { | |
| 312 this.pendingTasks_.push(this.resolveAbsolutePath.bind( | |
| 313 this, path, successCallback, errorCallback)); | |
| 314 return; | |
| 315 } | |
| 316 | |
| 317 // If the drive is disabled, any resolving the path under drive should be | |
| 318 // failed. | |
| 319 if (!this.driveEnabled_ && PathUtil.isDriveBasedPath(path)) { | |
| 320 errorCallback(util.createDOMError(util.FileError.NOT_FOUND_ERR)); | |
| 321 return; | |
| 322 } | |
| 323 | |
| 324 this.volumeManager_.resolveAbsolutePath(path, successCallback, errorCallback); | |
| 325 }; | |
| 326 | |
| 327 /** | |
| 328 * Filters volume info by referring driveEnabled. | 309 * Filters volume info by referring driveEnabled. |
| 329 * | 310 * |
| 330 * @param {VolumeInfo} volumeInfo Volume info. | 311 * @param {VolumeInfo} volumeInfo Volume info. |
| 331 * @return {VolumeInfo} Null if the drive is disabled and the given volume is | 312 * @return {VolumeInfo} Null if the drive is disabled and the given volume is |
| 332 * drive. Otherwise just returns the volume. | 313 * drive. Otherwise just returns the volume. |
| 333 * @private | 314 * @private |
| 334 */ | 315 */ |
| 335 VolumeManagerWrapper.prototype.filterDisabledDriveVolume_ = | 316 VolumeManagerWrapper.prototype.filterDisabledDriveVolume_ = |
| 336 function(volumeInfo) { | 317 function(volumeInfo) { |
| 337 var isDrive = volumeInfo && volumeInfo.volumeType === util.VolumeType.DRIVE; | 318 var isDrive = volumeInfo && volumeInfo.volumeType === util.VolumeType.DRIVE; |
| 338 return this.driveEnabled_ || !isDrive ? volumeInfo : null; | 319 return this.driveEnabled_ || !isDrive ? volumeInfo : null; |
| 339 }; | 320 }; |
| OLD | NEW |