| 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 * Type of a root directory. | 8 * Type of a root directory. |
| 9 * @enum | 9 * @enum |
| 10 */ | 10 */ |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 }; | 126 }; |
| 127 | 127 |
| 128 /** | 128 /** |
| 129 * @param {string} path Any path. | 129 * @param {string} path Any path. |
| 130 * @return {string} The root path. | 130 * @return {string} The root path. |
| 131 */ | 131 */ |
| 132 PathUtil.getRootPath = function(path) { | 132 PathUtil.getRootPath = function(path) { |
| 133 var type = PathUtil.getRootType(path); | 133 var type = PathUtil.getRootType(path); |
| 134 | 134 |
| 135 // TODO(haruki): Add support for "drive/root" and "drive/other". | 135 // TODO(haruki): Add support for "drive/root" and "drive/other". |
| 136 if (type == RootType.DOWNLOADS || type == RootType.DRIVE || | 136 if (type == RootType.DOWNLOADS || type == RootType.DRIVE_OFFLINE || |
| 137 type == RootType.DRIVE_OFFLINE || type == RootType.DRIVE_SHARED_WITH_ME) | 137 type == RootType.DRIVE_SHARED_WITH_ME) |
| 138 return PathUtil.getTopDirectory(path); | 138 return PathUtil.getTopDirectory(path); |
| 139 | 139 |
| 140 if (type == RootType.ARCHIVE || | 140 if (type == RootType.DRIVE || type == RootType.ARCHIVE || |
| 141 type == RootType.REMOVABLE) { | 141 type == RootType.REMOVABLE) { |
| 142 var components = PathUtil.split(path); | 142 var components = PathUtil.split(path); |
| 143 if (components.length > 1) { | 143 if (components.length > 1) { |
| 144 return PathUtil.join(components[0], components[1]); | 144 return PathUtil.join(components[0], components[1]); |
| 145 } else { | 145 } else { |
| 146 return components[0]; | 146 return components[0]; |
| 147 } | 147 } |
| 148 } | 148 } |
| 149 | 149 |
| 150 return '/'; | 150 return '/'; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 return str('ARCHIVE_DIRECTORY_LABEL'); | 206 return str('ARCHIVE_DIRECTORY_LABEL'); |
| 207 if (PathUtil.isParentPath(RootDirectory.ARCHIVE, path)) | 207 if (PathUtil.isParentPath(RootDirectory.ARCHIVE, path)) |
| 208 return path.substring(RootDirectory.ARCHIVE.length + 1); | 208 return path.substring(RootDirectory.ARCHIVE.length + 1); |
| 209 | 209 |
| 210 if (path === RootDirectory.REMOVABLE) | 210 if (path === RootDirectory.REMOVABLE) |
| 211 return str('REMOVABLE_DIRECTORY_LABEL'); | 211 return str('REMOVABLE_DIRECTORY_LABEL'); |
| 212 if (PathUtil.isParentPath(RootDirectory.REMOVABLE, path)) | 212 if (PathUtil.isParentPath(RootDirectory.REMOVABLE, path)) |
| 213 return path.substring(RootDirectory.REMOVABLE.length + 1); | 213 return path.substring(RootDirectory.REMOVABLE.length + 1); |
| 214 | 214 |
| 215 // TODO(haruki): Add support for "drive/root" and "drive/other". | 215 // TODO(haruki): Add support for "drive/root" and "drive/other". |
| 216 if (path === RootDirectory.DRIVE) | 216 if (path === RootDirectory.DRIVE + '/' + DriveSubRootDirectory.ROOT) |
| 217 return str('DRIVE_DIRECTORY_LABEL'); | 217 return str('DRIVE_DIRECTORY_LABEL'); |
| 218 | 218 |
| 219 if (path === RootDirectory.DRIVE_OFFLINE) | 219 if (path === RootDirectory.DRIVE_OFFLINE) |
| 220 return str('DRIVE_OFFLINE_COLLECTION_LABEL'); | 220 return str('DRIVE_OFFLINE_COLLECTION_LABEL'); |
| 221 | 221 |
| 222 if (path === RootDirectory.DRIVE_SHARED_WITH_ME) | 222 if (path === RootDirectory.DRIVE_SHARED_WITH_ME) |
| 223 return str('DRIVE_SHARED_WITH_ME_COLLECTION_LABEL'); | 223 return str('DRIVE_SHARED_WITH_ME_COLLECTION_LABEL'); |
| 224 | 224 |
| 225 return path; | 225 return path; |
| 226 }; | 226 }; |
| OLD | NEW |