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

Side by Side Diff: chrome/browser/resources/file_manager/background/js/volume_manager.js

Issue 135753003: Get rid of the fake Drive/root entry. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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 * Represents each volume, such as "drive", "download directory", each "USB 8 * Represents each volume, such as "drive", "download directory", each "USB
9 * flush storage", or "mounted zip archive" etc. 9 * flush storage", or "mounted zip archive" etc.
10 * 10 *
(...skipping 17 matching lines...) Expand all
28 root, 28 root,
29 error, 29 error,
30 deviceType, 30 deviceType,
31 isReadOnly, 31 isReadOnly,
32 profile) { 32 profile) {
33 this.volumeType = volumeType; 33 this.volumeType = volumeType;
34 // TODO(hidehiko): This should include FileSystem instance. 34 // TODO(hidehiko): This should include FileSystem instance.
35 this.mountPath = mountPath; 35 this.mountPath = mountPath;
36 this.volumeId = volumeId; 36 this.volumeId = volumeId;
37 this.root = root; 37 this.root = root;
38 this.displayRoot = null;
38 this.fakeEntries = {}; 39 this.fakeEntries = {};
40 this.resolveQueue_ = new AsyncUtil.Queue();
39 41
40 if (volumeType === util.VolumeType.DRIVE) { 42 if (volumeType === util.VolumeType.DRIVE) {
41 this.fakeEntries[RootType.DRIVE] = {
42 fullPath: RootDirectory.DRIVE + '/' + DriveSubRootDirectory.ROOT,
43 isDirectory: true,
44 rootType: RootType.DRIVE,
45 label: PathUtil.getRootLabel(RootType.DRIVE),
46 toURL: function() { return 'fake-entry://' + this.fullPath; }
47 };
48 this.fakeEntries[RootType.DRIVE_OFFLINE] = { 43 this.fakeEntries[RootType.DRIVE_OFFLINE] = {
49 fullPath: RootDirectory.DRIVE_OFFLINE, 44 fullPath: RootDirectory.DRIVE_OFFLINE,
50 isDirectory: true, 45 isDirectory: true,
51 rootType: RootType.DRIVE_OFFLINE, 46 rootType: RootType.DRIVE_OFFLINE,
52 label: PathUtil.getRootLabel(RootType.DRIVE_OFFLINE),
53 toURL: function() { return 'fake-entry://' + this.fullPath; } 47 toURL: function() { return 'fake-entry://' + this.fullPath; }
54 }; 48 };
55 this.fakeEntries[RootType.DRIVE_SHARED_WITH_ME] = { 49 this.fakeEntries[RootType.DRIVE_SHARED_WITH_ME] = {
56 fullPath: RootDirectory.DRIVE_SHARED_WITH_ME, 50 fullPath: RootDirectory.DRIVE_SHARED_WITH_ME,
57 isDirectory: true, 51 isDirectory: true,
58 rootType: RootType.DRIVE_SHARED_WITH_ME, 52 rootType: RootType.DRIVE_SHARED_WITH_ME,
59 label: PathUtil.getRootLabel(RootType.DRIVE_SHARED_WITH_ME),
60 toURL: function() { return 'fake-entry://' + this.fullPath; } 53 toURL: function() { return 'fake-entry://' + this.fullPath; }
61 }; 54 };
62 this.fakeEntries[RootType.DRIVE_RECENT] = { 55 this.fakeEntries[RootType.DRIVE_RECENT] = {
63 fullPath: RootDirectory.DRIVE_RECENT, 56 fullPath: RootDirectory.DRIVE_RECENT,
64 isDirectory: true, 57 isDirectory: true,
65 rootType: RootType.DRIVE_RECENT, 58 rootType: RootType.DRIVE_RECENT,
66 label: PathUtil.getRootLabel(RootType.DRIVE_RECENT),
67 toURL: function() { return 'fake-entry://' + this.fullPath; } 59 toURL: function() { return 'fake-entry://' + this.fullPath; }
68 }; 60 };
69 } 61 }
70 62
71 // Note: This represents if the mounting of the volume is successfully done 63 // Note: This represents if the mounting of the volume is successfully done
72 // or not. (If error is empty string, the mount is successfully done). 64 // or not. (If error is empty string, the mount is successfully done).
73 // TODO(hidehiko): Rename to make this more understandable. 65 // TODO(hidehiko): Rename to make this more understandable.
74 this.error = error; 66 this.error = error;
75 this.deviceType = deviceType; 67 this.deviceType = deviceType;
76 this.isReadOnly = isReadOnly; 68 this.isReadOnly = isReadOnly;
77 this.profile = Object.freeze(profile); 69 this.profile = Object.freeze(profile);
78 70
79 // VolumeInfo is immutable. 71 Object.seal(this);
yoshiki 2014/01/15 07:33:13 Since you're changing this class into non-immutabl
mtomasz 2014/01/16 01:31:58 Done.
80 Object.freeze(this);
81 } 72 }
82 73
83 /** 74 /**
84 * Obtains a URL of the display root directory that users can see as a root. 75 * Obtains a URL of the display root directory that users can see as a root.
85 * @return {string} URL of root entry. 76 * @return {string} URL of root entry.
77 * @private
86 */ 78 */
87 VolumeInfo.prototype.getDisplayRootDirectoryURL = function() { 79 VolumeInfo.prototype.getDisplayRootURL_ = function() {
88 return this.root.toURL() + 80 return this.root.toURL() +
yoshiki 2014/01/15 07:33:13 I'm not sure but this.root seems null-able, so ple
mtomasz 2014/01/16 01:31:58 In general I think we should not have a volumeInfo
yoshiki 2014/01/17 01:57:52 Ok. Got it.
89 (this.volumeType === util.VolumeType.DRIVE ? '/root' : ''); 81 (this.volumeType === util.VolumeType.DRIVE ? '/root' : '');
90 }; 82 };
91 83
92 /** 84 /**
85 * Obtains the display root of the entry. It may take long time for Drive. Once
86 * resolved, it is cached.
87 *
88 * @param {function(DirectoryEntry)} onSuccess Success callback with the display
89 * root directory as an argument.
90 * @param {function(FileError)} onFailure Failure callback.
91 */
92 VolumeInfo.prototype.resolveDisplayRoot = function(onSuccess, onFailure) {
yoshiki 2014/01/15 07:33:13 When on non-drive, can't we just use this.root?
mtomasz 2014/01/16 01:31:58 Done.
93 this.resolveQueue_.run(function(callback) {
94 if (this.displayRoot) {
95 onSuccess(this.displayRoot);
96 callback();
97 return;
98 }
99 webkitResolveLocalFileSystemURL(
100 this.getDisplayRootURL_(), function(directoryEntry) {
101 console.log('found', directoryEntry);
yoshiki 2014/01/15 07:33:13 nit: remove
mtomasz 2014/01/16 01:31:58 Done.
102 this.displayRoot = directoryEntry;
103 onSuccess(directoryEntry);
104 callback();
105 }.bind(this), function(fileError) {
106 console.log('not found', fileError);
yoshiki 2014/01/15 07:33:13 ditto
mtomasz 2014/01/16 01:31:58 Done.
107 onFailure(fileError);
108 callback();
109 }.bind(this));
110 }.bind(this));
111 };
112
113 /**
93 * Obtains volume label. 114 * Obtains volume label.
94 * @return {string} Label for the volume. 115 * @return {string} Label for the volume.
95 */ 116 */
96 VolumeInfo.prototype.getLabel = function() { 117 VolumeInfo.prototype.getLabel = function() {
97 if (this.volumeType === util.VolumeType.DRIVE) 118 if (this.volumeType === util.VolumeType.DRIVE)
98 return str('DRIVE_DIRECTORY_LABEL'); 119 return str('DRIVE_DIRECTORY_LABEL');
99 else 120 else
100 return PathUtil.getFolderLabel(this.mountPath); 121 return PathUtil.getFolderLabel(this.mountPath);
101 }; 122 };
102 123
(...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after
848 this.isDriveBased; 869 this.isDriveBased;
849 870
850 /** 871 /**
851 * Whether the entry is read only or not. 872 * Whether the entry is read only or not.
852 * @type {boolean} 873 * @type {boolean}
853 */ 874 */
854 this.isReadOnly = isReadOnly; 875 this.isReadOnly = isReadOnly;
855 876
856 Object.freeze(this); 877 Object.freeze(this);
857 } 878 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698