OLD | NEW |
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 #include "chrome/browser/chromeos/file_manager/volume_manager.h" | 5 #include "chrome/browser/chromeos/file_manager/volume_manager.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 | 137 |
138 Volume::Volume() | 138 Volume::Volume() |
139 : source_(SOURCE_FILE), | 139 : source_(SOURCE_FILE), |
140 type_(VOLUME_TYPE_GOOGLE_DRIVE), | 140 type_(VOLUME_TYPE_GOOGLE_DRIVE), |
141 device_type_(chromeos::DEVICE_TYPE_UNKNOWN), | 141 device_type_(chromeos::DEVICE_TYPE_UNKNOWN), |
142 mount_condition_(chromeos::disks::MOUNT_CONDITION_NONE), | 142 mount_condition_(chromeos::disks::MOUNT_CONDITION_NONE), |
143 mount_context_(MOUNT_CONTEXT_UNKNOWN), | 143 mount_context_(MOUNT_CONTEXT_UNKNOWN), |
144 is_parent_(false), | 144 is_parent_(false), |
145 is_read_only_(false), | 145 is_read_only_(false), |
146 has_media_(false), | 146 has_media_(false), |
147 configurable_(false) { | 147 configurable_(false), |
| 148 watchable_(false) { |
148 } | 149 } |
149 | 150 |
150 Volume::~Volume() { | 151 Volume::~Volume() { |
151 } | 152 } |
152 | 153 |
153 // static | 154 // static |
154 Volume* Volume::CreateForDrive(Profile* profile) { | 155 Volume* Volume::CreateForDrive(Profile* profile) { |
155 const base::FilePath& drive_path = | 156 const base::FilePath& drive_path = |
156 drive::util::GetDriveMountPointPath(profile); | 157 drive::util::GetDriveMountPointPath(profile); |
157 Volume* const volume = new Volume; | 158 Volume* const volume = new Volume; |
158 volume->type_ = VOLUME_TYPE_GOOGLE_DRIVE; | 159 volume->type_ = VOLUME_TYPE_GOOGLE_DRIVE; |
159 volume->device_type_ = chromeos::DEVICE_TYPE_UNKNOWN; | 160 volume->device_type_ = chromeos::DEVICE_TYPE_UNKNOWN; |
160 volume->source_path_ = drive_path; | 161 volume->source_path_ = drive_path; |
161 volume->source_ = SOURCE_NETWORK; | 162 volume->source_ = SOURCE_NETWORK; |
162 volume->mount_path_ = drive_path; | 163 volume->mount_path_ = drive_path; |
163 volume->mount_condition_ = chromeos::disks::MOUNT_CONDITION_NONE; | 164 volume->mount_condition_ = chromeos::disks::MOUNT_CONDITION_NONE; |
164 volume->volume_id_ = GenerateVolumeId(*volume); | 165 volume->volume_id_ = GenerateVolumeId(*volume); |
| 166 volume->watchable_ = true; |
165 return volume; | 167 return volume; |
166 } | 168 } |
167 | 169 |
168 // static | 170 // static |
169 Volume* Volume::CreateForDownloads(const base::FilePath& downloads_path) { | 171 Volume* Volume::CreateForDownloads(const base::FilePath& downloads_path) { |
170 Volume* const volume = new Volume; | 172 Volume* const volume = new Volume; |
171 volume->type_ = VOLUME_TYPE_DOWNLOADS_DIRECTORY; | 173 volume->type_ = VOLUME_TYPE_DOWNLOADS_DIRECTORY; |
172 volume->device_type_ = chromeos::DEVICE_TYPE_UNKNOWN; | 174 volume->device_type_ = chromeos::DEVICE_TYPE_UNKNOWN; |
173 // Keep source_path empty. | 175 // Keep source_path empty. |
174 volume->source_ = SOURCE_SYSTEM; | 176 volume->source_ = SOURCE_SYSTEM; |
175 volume->mount_path_ = downloads_path; | 177 volume->mount_path_ = downloads_path; |
176 volume->mount_condition_ = chromeos::disks::MOUNT_CONDITION_NONE; | 178 volume->mount_condition_ = chromeos::disks::MOUNT_CONDITION_NONE; |
177 volume->volume_id_ = GenerateVolumeId(*volume); | 179 volume->volume_id_ = GenerateVolumeId(*volume); |
| 180 volume->watchable_ = true; |
178 return volume; | 181 return volume; |
179 } | 182 } |
180 | 183 |
181 // static | 184 // static |
182 Volume* Volume::CreateForRemovable( | 185 Volume* Volume::CreateForRemovable( |
183 const chromeos::disks::DiskMountManager::MountPointInfo& mount_point, | 186 const chromeos::disks::DiskMountManager::MountPointInfo& mount_point, |
184 const chromeos::disks::DiskMountManager::Disk* disk) { | 187 const chromeos::disks::DiskMountManager::Disk* disk) { |
185 Volume* const volume = new Volume; | 188 Volume* const volume = new Volume; |
186 volume->type_ = MountTypeToVolumeType(mount_point.mount_type); | 189 volume->type_ = MountTypeToVolumeType(mount_point.mount_type); |
187 volume->source_path_ = base::FilePath(mount_point.source_path); | 190 volume->source_path_ = base::FilePath(mount_point.source_path); |
188 volume->source_ = mount_point.mount_type == chromeos::MOUNT_TYPE_ARCHIVE | 191 volume->source_ = mount_point.mount_type == chromeos::MOUNT_TYPE_ARCHIVE |
189 ? SOURCE_FILE | 192 ? SOURCE_FILE |
190 : SOURCE_DEVICE; | 193 : SOURCE_DEVICE; |
191 volume->mount_path_ = base::FilePath(mount_point.mount_path); | 194 volume->mount_path_ = base::FilePath(mount_point.mount_path); |
192 volume->mount_condition_ = mount_point.mount_condition; | 195 volume->mount_condition_ = mount_point.mount_condition; |
193 volume->volume_label_ = volume->mount_path().BaseName().AsUTF8Unsafe(); | 196 volume->volume_label_ = volume->mount_path().BaseName().AsUTF8Unsafe(); |
194 if (disk) { | 197 if (disk) { |
195 volume->device_type_ = disk->device_type(); | 198 volume->device_type_ = disk->device_type(); |
196 volume->system_path_prefix_ = base::FilePath(disk->system_path_prefix()); | 199 volume->system_path_prefix_ = base::FilePath(disk->system_path_prefix()); |
197 volume->is_parent_ = disk->is_parent(); | 200 volume->is_parent_ = disk->is_parent(); |
198 volume->is_read_only_ = disk->is_read_only(); | 201 volume->is_read_only_ = disk->is_read_only(); |
199 volume->has_media_ = disk->has_media(); | 202 volume->has_media_ = disk->has_media(); |
200 } else { | 203 } else { |
201 volume->device_type_ = chromeos::DEVICE_TYPE_UNKNOWN; | 204 volume->device_type_ = chromeos::DEVICE_TYPE_UNKNOWN; |
202 volume->is_read_only_ = | 205 volume->is_read_only_ = |
203 (mount_point.mount_type == chromeos::MOUNT_TYPE_ARCHIVE); | 206 (mount_point.mount_type == chromeos::MOUNT_TYPE_ARCHIVE); |
204 } | 207 } |
205 volume->volume_id_ = GenerateVolumeId(*volume); | 208 volume->volume_id_ = GenerateVolumeId(*volume); |
| 209 volume->watchable_ = true; |
206 return volume; | 210 return volume; |
207 } | 211 } |
208 | 212 |
209 // static | 213 // static |
210 Volume* Volume::CreateForProvidedFileSystem( | 214 Volume* Volume::CreateForProvidedFileSystem( |
211 const chromeos::file_system_provider::ProvidedFileSystemInfo& | 215 const chromeos::file_system_provider::ProvidedFileSystemInfo& |
212 file_system_info, | 216 file_system_info, |
213 MountContext mount_context) { | 217 MountContext mount_context) { |
214 Volume* const volume = new Volume; | 218 Volume* const volume = new Volume; |
215 volume->file_system_id_ = file_system_info.file_system_id(); | 219 volume->file_system_id_ = file_system_info.file_system_id(); |
(...skipping 10 matching lines...) Expand all Loading... |
226 break; | 230 break; |
227 } | 231 } |
228 volume->volume_label_ = file_system_info.display_name(); | 232 volume->volume_label_ = file_system_info.display_name(); |
229 volume->type_ = VOLUME_TYPE_PROVIDED; | 233 volume->type_ = VOLUME_TYPE_PROVIDED; |
230 volume->mount_path_ = file_system_info.mount_path(); | 234 volume->mount_path_ = file_system_info.mount_path(); |
231 volume->mount_condition_ = chromeos::disks::MOUNT_CONDITION_NONE; | 235 volume->mount_condition_ = chromeos::disks::MOUNT_CONDITION_NONE; |
232 volume->mount_context_ = mount_context; | 236 volume->mount_context_ = mount_context; |
233 volume->is_parent_ = true; | 237 volume->is_parent_ = true; |
234 volume->is_read_only_ = !file_system_info.writable(); | 238 volume->is_read_only_ = !file_system_info.writable(); |
235 volume->configurable_ = file_system_info.configurable(); | 239 volume->configurable_ = file_system_info.configurable(); |
| 240 volume->watchable_ = file_system_info.watchable(); |
236 volume->volume_id_ = GenerateVolumeId(*volume); | 241 volume->volume_id_ = GenerateVolumeId(*volume); |
237 return volume; | 242 return volume; |
238 } | 243 } |
239 | 244 |
240 // static | 245 // static |
241 Volume* Volume::CreateForMTP(const base::FilePath& mount_path, | 246 Volume* Volume::CreateForMTP(const base::FilePath& mount_path, |
242 const std::string& label, | 247 const std::string& label, |
243 bool read_only) { | 248 bool read_only) { |
244 Volume* const volume = new Volume; | 249 Volume* const volume = new Volume; |
245 volume->type_ = VOLUME_TYPE_MTP; | 250 volume->type_ = VOLUME_TYPE_MTP; |
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
867 if (mounted_volumes_.find(volume->volume_id()) == mounted_volumes_.end()) | 872 if (mounted_volumes_.find(volume->volume_id()) == mounted_volumes_.end()) |
868 return; | 873 return; |
869 if (error_code == chromeos::MOUNT_ERROR_NONE) | 874 if (error_code == chromeos::MOUNT_ERROR_NONE) |
870 mounted_volumes_.erase(volume->volume_id()); | 875 mounted_volumes_.erase(volume->volume_id()); |
871 | 876 |
872 FOR_EACH_OBSERVER(VolumeManagerObserver, observers_, | 877 FOR_EACH_OBSERVER(VolumeManagerObserver, observers_, |
873 OnVolumeUnmounted(error_code, *volume.get())); | 878 OnVolumeUnmounted(error_code, *volume.get())); |
874 } | 879 } |
875 | 880 |
876 } // namespace file_manager | 881 } // namespace file_manager |
OLD | NEW |