OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 'use strict'; | 5 'use strict'; |
6 | 6 |
7 /** | 7 /** |
8 * Represents each volume, such as "drive", "download directory", each "USB | 8 * Represents each volume, such as "drive", "download directory", each "USB |
9 * flush storage", or "mounted zip archive" etc. | 9 * flush storage", or "mounted zip archive" etc. |
10 * | 10 * |
(...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
688 if ((entry.fullPath + '/').indexOf(volumeInfo.mountPath + '/root/') === 0) { | 688 if ((entry.fullPath + '/').indexOf(volumeInfo.mountPath + '/root/') === 0) { |
689 rootPath = volumeInfo.mountPath + '/root'; | 689 rootPath = volumeInfo.mountPath + '/root'; |
690 rootType = RootType.DRIVE; | 690 rootType = RootType.DRIVE; |
691 isReadOnly = volumeInfo.isReadOnly; | 691 isReadOnly = volumeInfo.isReadOnly; |
692 } else if ((entry.fullPath + '/').indexOf( | 692 } else if ((entry.fullPath + '/').indexOf( |
693 volumeInfo.mountPath + '/other/') === 0) { | 693 volumeInfo.mountPath + '/other/') === 0) { |
694 rootPath = volumeInfo.mountPath + '/other'; | 694 rootPath = volumeInfo.mountPath + '/other'; |
695 rootType = RootType.DRIVE_OTHER; | 695 rootType = RootType.DRIVE_OTHER; |
696 isReadOnly = true; | 696 isReadOnly = true; |
697 } else { | 697 } else { |
698 throw new Error(entry.fullPath + ' is an invalid drive path.'); | 698 // Accessing Drive files outside of /drive/root and /drive/other is not |
| 699 // allowed, but can happen. Therefore returning null. |
| 700 return null; |
699 } | 701 } |
700 } else { | 702 } else { |
701 // Otherwise, root path is same with a mount path of the volume. | 703 // Otherwise, root path is same with a mount path of the volume. |
702 rootPath = volumeInfo.mountPath; | 704 rootPath = volumeInfo.mountPath; |
703 switch (volumeInfo.volumeType) { | 705 switch (volumeInfo.volumeType) { |
704 case util.VolumeType.DOWNLOADS: | 706 case util.VolumeType.DOWNLOADS: |
705 rootType = RootType.DOWNLOADS; | 707 rootType = RootType.DOWNLOADS; |
706 break; | 708 break; |
707 case util.VolumeType.REMOVABLE: | 709 case util.VolumeType.REMOVABLE: |
708 rootType = RootType.REMOVABLE; | 710 rootType = RootType.REMOVABLE; |
709 break; | 711 break; |
710 case util.VolumeType.ARCHIVE: | 712 case util.VolumeType.ARCHIVE: |
711 rootType = RootType.ARCHIVE; | 713 rootType = RootType.ARCHIVE; |
712 break; | 714 break; |
713 case util.VolumeType.CLOUD_DEVICE: | 715 case util.VolumeType.CLOUD_DEVICE: |
714 rootType = RootType.CLOUD_DEVICE; | 716 rootType = RootType.CLOUD_DEVICE; |
715 break; | 717 break; |
716 default: | 718 default: |
| 719 // Programming error, throw an exception. |
717 throw new Error('Invalid volume type: ' + volumeInfo.volumeType); | 720 throw new Error('Invalid volume type: ' + volumeInfo.volumeType); |
718 } | 721 } |
719 isReadOnly = volumeInfo.isReadOnly; | 722 isReadOnly = volumeInfo.isReadOnly; |
720 } | 723 } |
721 var isRootEntry = (entry.fullPath.substr(0, rootPath.length) || '/') === | 724 var isRootEntry = (entry.fullPath.substr(0, rootPath.length) || '/') === |
722 entry.fullPath; | 725 entry.fullPath; |
723 | 726 |
724 return new EntryLocation(volumeInfo, rootType, isRootEntry, isReadOnly); | 727 return new EntryLocation(volumeInfo, rootType, isRootEntry, isReadOnly); |
725 }; | 728 }; |
726 | 729 |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
859 this.isDriveBased; | 862 this.isDriveBased; |
860 | 863 |
861 /** | 864 /** |
862 * Whether the entry is read only or not. | 865 * Whether the entry is read only or not. |
863 * @type {boolean} | 866 * @type {boolean} |
864 */ | 867 */ |
865 this.isReadOnly = isReadOnly; | 868 this.isReadOnly = isReadOnly; |
866 | 869 |
867 Object.freeze(this); | 870 Object.freeze(this); |
868 } | 871 } |
OLD | NEW |