Chromium Code Reviews| Index: chrome/browser/resources/file_manager/js/path_util.js |
| diff --git a/chrome/browser/resources/file_manager/js/path_util.js b/chrome/browser/resources/file_manager/js/path_util.js |
| index fb31fb10038f1ae5559d1b6690d078a4cc03a0c8..1df2d2b44822129e925289da8ab0723dddb40ed5 100644 |
| --- a/chrome/browser/resources/file_manager/js/path_util.js |
| +++ b/chrome/browser/resources/file_manager/js/path_util.js |
| @@ -26,15 +26,24 @@ var RootDirectory = { |
| DRIVE_OFFLINE: '/drive_offline' // A fake root. Not the actual filesystem. |
| }; |
| +/** |
| + * Sub root directory for Drive. "root" and "other". |
|
yoshiki
2013/03/15 06:26:58
nit: This seems not to be used now. Please add som
Haruki Sato
2013/03/15 06:49:47
Done. Thanks.
|
| + * @enum |
| + */ |
| +var DriveSubRootDirectory = { |
| + ROOT: 'root', |
| + OTHER: 'other', |
| +}; |
| + |
| var PathUtil = {}; |
| /** |
| * @param {string} path Path starting with '/'. |
| - * @return {string} Root directory (starting with '/'). |
| + * @return {string} Top directory (starting with '/'). |
| */ |
| -PathUtil.getRootDirectory = function(path) { |
| +PathUtil.getTopDirectory = function(path) { |
| var i = path.indexOf('/', 1); |
| - return i === -1 ? path.substring(0) : path.substring(0, i); |
| + return i === -1 ? path : path.substring(0, i); |
| }; |
| /** |
| @@ -92,7 +101,7 @@ PathUtil.join = function() { |
| * @return {RootType} RootType.DOWNLOADS, RootType.DRIVE etc. |
| */ |
| PathUtil.getRootType = function(path) { |
| - var rootDir = PathUtil.getRootDirectory(path); |
| + var rootDir = PathUtil.getTopDirectory(path); |
| for (var type in RootDirectory) { |
| if (rootDir === RootDirectory[type]) |
| return RootType[type]; |
| @@ -106,11 +115,13 @@ PathUtil.getRootType = function(path) { |
| PathUtil.getRootPath = function(path) { |
| var type = PathUtil.getRootType(path); |
| + // TODO(haruki): Add support for "drive/root" and "drive/other". |
| if (type == RootType.DOWNLOADS || type == RootType.DRIVE || |
| type == RootType.DRIVE_OFFLINE) |
| - return PathUtil.getRootDirectory(path); |
| + return PathUtil.getTopDirectory(path); |
| - if (type == RootType.ARCHIVE || type == RootType.REMOVABLE) { |
| + if (type == RootType.ARCHIVE || |
| + type == RootType.REMOVABLE) { |
| var components = PathUtil.split(path); |
| if (components.length > 1) { |
| return PathUtil.join(components[0], components[1]); |
| @@ -172,6 +183,7 @@ PathUtil.getRootLabel = function(path) { |
| if (PathUtil.isParentPath(RootDirectory.REMOVABLE, path)) |
| return path.substring(RootDirectory.REMOVABLE.length + 1); |
| + // TODO(haruki): Add support for "drive/root" and "drive/other". |
| if (path === RootDirectory.DRIVE) |
| return str('DRIVE_DIRECTORY_LABEL'); |