Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8123)

Unified Diff: chrome/browser/resources/file_manager/js/path_util.js

Issue 12716015: filemanager: Files App change necessary to use "drive/root". It still works with "drive". (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix comments. Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..aa32084570d0dc91ffe6eca03bb344a8eed2ba61 100644
--- a/chrome/browser/resources/file_manager/js/path_util.js
+++ b/chrome/browser/resources/file_manager/js/path_util.js
@@ -26,15 +26,25 @@ var RootDirectory = {
DRIVE_OFFLINE: '/drive_offline' // A fake root. Not the actual filesystem.
};
+/**
+ * Sub root directory for Drive. "root" and "other". This is not used now.
+ * TODO(haruki): Add namespaces support. http://crbug.com/174233.
+ * @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 +102,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 +116,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 +184,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');
« no previous file with comments | « chrome/browser/resources/file_manager/js/file_manager.js ('k') | chrome/browser/resources/file_manager/js/volume_manager.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698