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

Side by Side Diff: chrome/browser/resources/file_manager/common/js/util.js

Issue 179553008: Simplify volume manager in Files app. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed unmounting. Created 6 years, 10 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 'use strict'; 5 'use strict';
6 6
7 /** 7 /**
8 * Namespace for utility functions. 8 * Namespace for utility functions.
9 */ 9 */
10 var util = {}; 10 var util = {};
(...skipping 1061 matching lines...) Expand 10 before | Expand all | Expand 10 after
1072 }; 1072 };
1073 1073
1074 /** 1074 /**
1075 * Compares two entries. 1075 * Compares two entries.
1076 * @param {Entry|Object} entry1 The entry to be compared. Can be a fake. 1076 * @param {Entry|Object} entry1 The entry to be compared. Can be a fake.
1077 * @param {Entry|Object} entry2 The entry to be compared. Can be a fake. 1077 * @param {Entry|Object} entry2 The entry to be compared. Can be a fake.
1078 * @return {boolean} True if the both entry represents a same file or 1078 * @return {boolean} True if the both entry represents a same file or
1079 * directory. Returns true if both entries are null. 1079 * directory. Returns true if both entries are null.
1080 */ 1080 */
1081 util.isSameEntry = function(entry1, entry2) { 1081 util.isSameEntry = function(entry1, entry2) {
1082 // Currently, we can assume there is only one root. 1082 if (!entry1 && !entry2)
1083 // When we support multi-file system, we need to look at filesystem, too. 1083 return true;
1084 return (entry1 && entry2 && entry1.toURL() === entry2.toURL()) || 1084 if (!entry1 || !entry2)
1085 (!entry1 && !entry2); 1085 return false;
1086 return entry1.toURL() === entry2.toURL();
1086 }; 1087 };
1087 1088
1088 /** 1089 /**
1090 * Compares two file systems.
1091 * @param {DOMFileSystem} fileSystem1 The file system to be compared.
1092 * @param {DOMFileSystem} fileSystem2 The file system to be compared.
1093 * @return {boolean} True if the both file systems are equal. Also, returns true
1094 * if both file systems are null.
1095 */
1096 util.isSameFileSystem = function(fileSystem1, fileSystem2) {
1097 if (!fileSystem1 && !fileSystem2)
1098 return true;
1099 if (!fileSystem1 || !fileSystem2)
1100 return false;
1101 return util.isSameEntry(fileSystem1.root, fileSystem2.root);
1102 };
1103
1104 /**
1089 * Checks if the child entry is a descendant of another entry. If the entries 1105 * Checks if the child entry is a descendant of another entry. If the entries
1090 * point to the same file or directory, then returns false. 1106 * point to the same file or directory, then returns false.
1091 * 1107 *
1092 * @param {DirectoryEntry|Object} ancestorEntry The ancestor directory entry. 1108 * @param {DirectoryEntry|Object} ancestorEntry The ancestor directory entry.
1093 * Can be a fake. 1109 * Can be a fake.
1094 * @param {Entry|Object} childEntry The child entry. Can be a fake. 1110 * @param {Entry|Object} childEntry The child entry. Can be a fake.
1095 * @return {boolean} True if the child entry is contained in the ancestor path. 1111 * @return {boolean} True if the child entry is contained in the ancestor path.
1096 */ 1112 */
1097 util.isDescendantEntry = function(ancestorEntry, childEntry) { 1113 util.isDescendantEntry = function(ancestorEntry, childEntry) {
1098 if (!ancestorEntry.isDirectory) 1114 if (!ancestorEntry.isDirectory)
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
1280 * @enum {string} 1296 * @enum {string}
1281 * @const 1297 * @const
1282 */ 1298 */
1283 util.VolumeType = Object.freeze({ 1299 util.VolumeType = Object.freeze({
1284 DRIVE: 'drive', 1300 DRIVE: 'drive',
1285 DOWNLOADS: 'downloads', 1301 DOWNLOADS: 'downloads',
1286 REMOVABLE: 'removable', 1302 REMOVABLE: 'removable',
1287 ARCHIVE: 'archive', 1303 ARCHIVE: 'archive',
1288 CLOUD_DEVICE: 'cloud_device' 1304 CLOUD_DEVICE: 'cloud_device'
1289 }); 1305 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698