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

Side by Side Diff: chrome/browser/chromeos/file_manager/volume_manager.h

Issue 1137383002: Show the eject button only for removabled and file handlers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments + fixed tests. Created 5 years, 7 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #ifndef CHROME_BROWSER_CHROMEOS_FILE_MANAGER_VOLUME_MANAGER_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_FILE_MANAGER_VOLUME_MANAGER_H_
6 #define CHROME_BROWSER_CHROMEOS_FILE_MANAGER_VOLUME_MANAGER_H_ 6 #define CHROME_BROWSER_CHROMEOS_FILE_MANAGER_VOLUME_MANAGER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 59
60 // Says how was the mount performed, whether due to user interaction, or 60 // Says how was the mount performed, whether due to user interaction, or
61 // automatic. User interaction includes both hardware (pluggins a USB stick) 61 // automatic. User interaction includes both hardware (pluggins a USB stick)
62 // or software (mounting a ZIP archive) interaction. 62 // or software (mounting a ZIP archive) interaction.
63 enum MountContext { 63 enum MountContext {
64 MOUNT_CONTEXT_USER, 64 MOUNT_CONTEXT_USER,
65 MOUNT_CONTEXT_AUTO, 65 MOUNT_CONTEXT_AUTO,
66 MOUNT_CONTEXT_UNKNOWN 66 MOUNT_CONTEXT_UNKNOWN
67 }; 67 };
68 68
69 // Source of a volume's data.
70 enum Source { SOURCE_FILE, SOURCE_DEVICE, SOURCE_NETWORK, SOURCE_SYSTEM };
71
69 // Represents a volume (mount point) in the volume manager. Validity of the data 72 // Represents a volume (mount point) in the volume manager. Validity of the data
70 // is guaranteed by the weak pointer. Simply saying, the weak pointer should be 73 // is guaranteed by the weak pointer. Simply saying, the weak pointer should be
71 // valid as long as the volume is mounted. 74 // valid as long as the volume is mounted.
72 class Volume : public base::SupportsWeakPtr<Volume> { 75 class Volume : public base::SupportsWeakPtr<Volume> {
73 public: 76 public:
74 ~Volume(); 77 ~Volume();
75 78
76 // Factory static methods for different volume types. 79 // Factory static methods for different volume types.
77 static Volume* CreateForDrive(Profile* profile); 80 static Volume* CreateForDrive(Profile* profile);
78 static Volume* CreateForDownloads(const base::FilePath& downloads_path); 81 static Volume* CreateForDownloads(const base::FilePath& downloads_path);
(...skipping 11 matching lines...) Expand all
90 VolumeType volume_type, 93 VolumeType volume_type,
91 chromeos::DeviceType device_type, 94 chromeos::DeviceType device_type,
92 bool read_only); 95 bool read_only);
93 static Volume* CreateForTesting(const base::FilePath& device_path, 96 static Volume* CreateForTesting(const base::FilePath& device_path,
94 const base::FilePath& mount_path); 97 const base::FilePath& mount_path);
95 98
96 // Getters for all members. See below for details. 99 // Getters for all members. See below for details.
97 const std::string& volume_id() const { return volume_id_; } 100 const std::string& volume_id() const { return volume_id_; }
98 const std::string& file_system_id() const { return file_system_id_; } 101 const std::string& file_system_id() const { return file_system_id_; }
99 const std::string& extension_id() const { return extension_id_; } 102 const std::string& extension_id() const { return extension_id_; }
103 const Source source() const { return source_; }
hirono 2015/05/15 08:27:45 nit for return type: const Source -> Source ?
mtomasz 2015/05/15 09:32:37 Done.
100 VolumeType type() const { return type_; } 104 VolumeType type() const { return type_; }
101 chromeos::DeviceType device_type() const { return device_type_; } 105 chromeos::DeviceType device_type() const { return device_type_; }
102 const base::FilePath& source_path() const { return source_path_; } 106 const base::FilePath& source_path() const { return source_path_; }
103 const base::FilePath& mount_path() const { return mount_path_; } 107 const base::FilePath& mount_path() const { return mount_path_; }
104 chromeos::disks::MountCondition mount_condition() const { 108 chromeos::disks::MountCondition mount_condition() const {
105 return mount_condition_; 109 return mount_condition_;
106 } 110 }
107 MountContext mount_context() const { return mount_context_; } 111 MountContext mount_context() const { return mount_context_; }
108 const base::FilePath& system_path_prefix() const { 112 const base::FilePath& system_path_prefix() const {
109 return system_path_prefix_; 113 return system_path_prefix_;
110 } 114 }
111 const std::string& volume_label() const { return volume_label_; } 115 const std::string& volume_label() const { return volume_label_; }
112 bool is_parent() const { return is_parent_; } 116 bool is_parent() const { return is_parent_; }
113 bool is_read_only() const { return is_read_only_; } 117 bool is_read_only() const { return is_read_only_; }
114 bool has_media() const { return has_media_; } 118 bool has_media() const { return has_media_; }
119 bool configurable() const { return configurable_; }
115 120
116 private: 121 private:
117 Volume(); 122 Volume();
118 123
119 // The ID of the volume. 124 // The ID of the volume.
120 std::string volume_id_; 125 std::string volume_id_;
121 126
122 // The ID for provided file systems. If other type, then empty string. Unique 127 // The ID for provided file systems. If other type, then empty string. Unique
123 // per providing extension. 128 // per providing extension.
124 std::string file_system_id_; 129 std::string file_system_id_;
125 130
126 // The ID of an extension providing the file system. If other type, then equal 131 // The ID of an extension providing the file system. If other type, then equal
127 // to an empty string. 132 // to an empty string.
128 std::string extension_id_; 133 std::string extension_id_;
129 134
135 // The source of the volume's data.
136 Source source_;
137
130 // The type of mounted volume. 138 // The type of mounted volume.
131 VolumeType type_; 139 VolumeType type_;
132 140
133 // The type of device. (e.g. USB, SD card, DVD etc.) 141 // The type of device. (e.g. USB, SD card, DVD etc.)
134 chromeos::DeviceType device_type_; 142 chromeos::DeviceType device_type_;
135 143
136 // The source path of the volume. 144 // The source path of the volume.
137 // E.g.: 145 // E.g.:
138 // - /home/chronos/user/Downloads/zipfile_path.zip 146 // - /home/chronos/user/Downloads/zipfile_path.zip
139 base::FilePath source_path_; 147 base::FilePath source_path_;
(...skipping 23 matching lines...) Expand all
163 171
164 // Is the device is a parent device (i.e. sdb rather than sdb1). 172 // Is the device is a parent device (i.e. sdb rather than sdb1).
165 bool is_parent_; 173 bool is_parent_;
166 174
167 // True if the volume is read only. 175 // True if the volume is read only.
168 bool is_read_only_; 176 bool is_read_only_;
169 177
170 // True if the volume contains media. 178 // True if the volume contains media.
171 bool has_media_; 179 bool has_media_;
172 180
181 // True if the volume is configurable.
182 bool configurable_;
183
173 DISALLOW_COPY_AND_ASSIGN(Volume); 184 DISALLOW_COPY_AND_ASSIGN(Volume);
174 }; 185 };
175 186
176 // Manages "Volume"s for file manager. Here are "Volume"s. 187 // Manages "Volume"s for file manager. Here are "Volume"s.
177 // - Drive File System (not yet supported). 188 // - Drive File System (not yet supported).
178 // - Downloads directory. 189 // - Downloads directory.
179 // - Removable disks (volume will be created for each partition, not only one 190 // - Removable disks (volume will be created for each partition, not only one
180 // for a device). 191 // for a device).
181 // - Mounted zip archives. 192 // - Mounted zip archives.
182 class VolumeManager : public KeyedService, 193 class VolumeManager : public KeyedService,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 // |path| with DOWNLOADS type, and adds its volume info. 232 // |path| with DOWNLOADS type, and adds its volume info.
222 bool RegisterDownloadsDirectoryForTesting(const base::FilePath& path); 233 bool RegisterDownloadsDirectoryForTesting(const base::FilePath& path);
223 234
224 // For testing purpose, adds a volume info pointing to |path|, with TESTING 235 // For testing purpose, adds a volume info pointing to |path|, with TESTING
225 // type. Assumes that the mount point is already registered. 236 // type. Assumes that the mount point is already registered.
226 void AddVolumeForTesting(const base::FilePath& path, 237 void AddVolumeForTesting(const base::FilePath& path,
227 VolumeType volume_type, 238 VolumeType volume_type,
228 chromeos::DeviceType device_type, 239 chromeos::DeviceType device_type,
229 bool read_only); 240 bool read_only);
230 241
242 // For testing purpose, adds the volume info to the volume manager.
243 void AddVolumeForTesting(linked_ptr<Volume> volume);
hirono 2015/05/15 08:27:45 nit: const linked_ptr<Volume>& volume ?
mtomasz 2015/05/15 09:32:37 I was considering it, but it seemed that linked_pt
244
231 // drive::DriveIntegrationServiceObserver overrides. 245 // drive::DriveIntegrationServiceObserver overrides.
232 void OnFileSystemMounted() override; 246 void OnFileSystemMounted() override;
233 void OnFileSystemBeingUnmounted() override; 247 void OnFileSystemBeingUnmounted() override;
234 248
235 // chromeos::disks::DiskMountManager::Observer overrides. 249 // chromeos::disks::DiskMountManager::Observer overrides.
236 void OnDiskEvent( 250 void OnDiskEvent(
237 chromeos::disks::DiskMountManager::DiskEvent event, 251 chromeos::disks::DiskMountManager::DiskEvent event,
238 const chromeos::disks::DiskMountManager::Disk* disk) override; 252 const chromeos::disks::DiskMountManager::Disk* disk) override;
239 void OnDeviceEvent(chromeos::disks::DiskMountManager::DeviceEvent event, 253 void OnDeviceEvent(chromeos::disks::DiskMountManager::DeviceEvent event,
240 const std::string& device_path) override; 254 const std::string& device_path) override;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 301
288 // Note: This should remain the last member so it'll be destroyed and 302 // Note: This should remain the last member so it'll be destroyed and
289 // invalidate its weak pointers before any other members are destroyed. 303 // invalidate its weak pointers before any other members are destroyed.
290 base::WeakPtrFactory<VolumeManager> weak_ptr_factory_; 304 base::WeakPtrFactory<VolumeManager> weak_ptr_factory_;
291 DISALLOW_COPY_AND_ASSIGN(VolumeManager); 305 DISALLOW_COPY_AND_ASSIGN(VolumeManager);
292 }; 306 };
293 307
294 } // namespace file_manager 308 } // namespace file_manager
295 309
296 #endif // CHROME_BROWSER_CHROMEOS_FILE_MANAGER_VOLUME_MANAGER_H_ 310 #endif // CHROME_BROWSER_CHROMEOS_FILE_MANAGER_VOLUME_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698