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

Side by Side Diff: chrome/browser/resources/file_manager/js/path_util.js

Issue 12857002: Files.app: Add subfolders in the left nav (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 /** 5 /**
6 * Type of a root directory. 6 * Type of a root directory.
7 * @enum 7 * @enum
8 */ 8 */
9 var RootType = { 9 var RootType = {
10 DOWNLOADS: 'downloads', 10 DOWNLOADS: 'downloads',
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 124
125 /** 125 /**
126 * @param {string} path A path. 126 * @param {string} path A path.
127 * @return {boolean} True if it is a path to the root. 127 * @return {boolean} True if it is a path to the root.
128 */ 128 */
129 PathUtil.isRootPath = function(path) { 129 PathUtil.isRootPath = function(path) {
130 return PathUtil.getRootPath(path) === path; 130 return PathUtil.getRootPath(path) === path;
131 }; 131 };
132 132
133 /** 133 /**
134 * @param {string} path A root path.
135 * @return {boolean} True if the given path is root and user can unmount it.
136 */
137 PathUtil.isUnmountableByUser = function(path) {
138 if (!PathUtil.isRootPath(path))
139 return false;
140
141 var type = PathUtil.getRootType(path);
142 return (type == RootType.ARCHIVE || type == RootType.REMOVABLE);
143 };
144
145 /**
134 * @param {string} parent_path The parent path. 146 * @param {string} parent_path The parent path.
135 * @param {string} child_path The child path. 147 * @param {string} child_path The child path.
136 * @return {boolean} True if |parent_path| is parent file path of |child_path|. 148 * @return {boolean} True if |parent_path| is parent file path of |child_path|.
137 */ 149 */
138 PathUtil.isParentPath = function(parent_path, child_path) { 150 PathUtil.isParentPath = function(parent_path, child_path) {
139 if (!parent_path || parent_path.length == 0 || 151 if (!parent_path || parent_path.length == 0 ||
140 !child_path || child_path.length == 0) 152 !child_path || child_path.length == 0)
141 return false; 153 return false;
142 154
143 if (parent_path[parent_path.length - 1] != '/') 155 if (parent_path[parent_path.length - 1] != '/')
(...skipping 29 matching lines...) Expand all
173 return path.substring(RootDirectory.REMOVABLE.length + 1); 185 return path.substring(RootDirectory.REMOVABLE.length + 1);
174 186
175 if (path === RootDirectory.DRIVE) 187 if (path === RootDirectory.DRIVE)
176 return str('DRIVE_DIRECTORY_LABEL'); 188 return str('DRIVE_DIRECTORY_LABEL');
177 189
178 if (path === RootDirectory.DRIVE_OFFLINE) 190 if (path === RootDirectory.DRIVE_OFFLINE)
179 return str('DRIVE_OFFLINE_COLLECTION_LABEL'); 191 return str('DRIVE_OFFLINE_COLLECTION_LABEL');
180 192
181 return path; 193 return path;
182 }; 194 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698