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/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 volume_info.mount_condition = chromeos::disks::MOUNT_CONDITION_NONE; | 146 volume_info.mount_condition = chromeos::disks::MOUNT_CONDITION_NONE; |
147 volume_info.is_parent = false; | 147 volume_info.is_parent = false; |
148 volume_info.is_read_only = false; | 148 volume_info.is_read_only = false; |
149 volume_info.has_media = false; | 149 volume_info.has_media = false; |
150 volume_info.volume_id = GenerateVolumeId(volume_info); | 150 volume_info.volume_id = GenerateVolumeId(volume_info); |
151 return volume_info; | 151 return volume_info; |
152 } | 152 } |
153 | 153 |
154 VolumeInfo CreateTestingVolumeInfo(const base::FilePath& path, | 154 VolumeInfo CreateTestingVolumeInfo(const base::FilePath& path, |
155 VolumeType volume_type, | 155 VolumeType volume_type, |
156 chromeos::DeviceType device_type) { | 156 chromeos::DeviceType device_type, |
| 157 bool read_only) { |
157 VolumeInfo volume_info; | 158 VolumeInfo volume_info; |
158 volume_info.type = volume_type; | 159 volume_info.type = volume_type; |
159 volume_info.device_type = device_type; | 160 volume_info.device_type = device_type; |
160 // Keep source_path empty. | 161 // Keep source_path empty. |
161 volume_info.mount_path = path; | 162 volume_info.mount_path = path; |
162 volume_info.mount_condition = chromeos::disks::MOUNT_CONDITION_NONE; | 163 volume_info.mount_condition = chromeos::disks::MOUNT_CONDITION_NONE; |
163 volume_info.is_parent = false; | 164 volume_info.is_parent = false; |
164 volume_info.is_read_only = false; | 165 volume_info.is_read_only = read_only; |
165 volume_info.has_media = false; | 166 volume_info.has_media = false; |
166 volume_info.volume_id = GenerateVolumeId(volume_info); | 167 volume_info.volume_id = GenerateVolumeId(volume_info); |
167 return volume_info; | 168 return volume_info; |
168 } | 169 } |
169 | 170 |
170 VolumeInfo CreateVolumeInfoFromMountPointInfo( | 171 VolumeInfo CreateVolumeInfoFromMountPointInfo( |
171 const chromeos::disks::DiskMountManager::MountPointInfo& mount_point, | 172 const chromeos::disks::DiskMountManager::MountPointInfo& mount_point, |
172 const chromeos::disks::DiskMountManager::Disk* disk) { | 173 const chromeos::disks::DiskMountManager::Disk* disk) { |
173 VolumeInfo volume_info; | 174 VolumeInfo volume_info; |
174 volume_info.type = MountTypeToVolumeType(mount_point.mount_type); | 175 volume_info.type = MountTypeToVolumeType(mount_point.mount_type); |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 | 384 |
384 bool success = RegisterDownloadsMountPoint(profile_, path); | 385 bool success = RegisterDownloadsMountPoint(profile_, path); |
385 DoMountEvent( | 386 DoMountEvent( |
386 success ? chromeos::MOUNT_ERROR_NONE : chromeos::MOUNT_ERROR_INVALID_PATH, | 387 success ? chromeos::MOUNT_ERROR_NONE : chromeos::MOUNT_ERROR_INVALID_PATH, |
387 CreateDownloadsVolumeInfo(path)); | 388 CreateDownloadsVolumeInfo(path)); |
388 return success; | 389 return success; |
389 } | 390 } |
390 | 391 |
391 void VolumeManager::AddVolumeInfoForTesting(const base::FilePath& path, | 392 void VolumeManager::AddVolumeInfoForTesting(const base::FilePath& path, |
392 VolumeType volume_type, | 393 VolumeType volume_type, |
393 chromeos::DeviceType device_type) { | 394 chromeos::DeviceType device_type, |
| 395 bool read_only) { |
394 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 396 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
395 DoMountEvent(chromeos::MOUNT_ERROR_NONE, | 397 DoMountEvent( |
396 CreateTestingVolumeInfo(path, volume_type, device_type)); | 398 chromeos::MOUNT_ERROR_NONE, |
| 399 CreateTestingVolumeInfo(path, volume_type, device_type, read_only)); |
397 } | 400 } |
398 | 401 |
399 void VolumeManager::OnFileSystemMounted() { | 402 void VolumeManager::OnFileSystemMounted() { |
400 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 403 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
401 | 404 |
402 // Raise mount event. | 405 // Raise mount event. |
403 // We can pass chromeos::MOUNT_ERROR_NONE even when authentication is failed | 406 // We can pass chromeos::MOUNT_ERROR_NONE even when authentication is failed |
404 // or network is unreachable. These two errors will be handled later. | 407 // or network is unreachable. These two errors will be handled later. |
405 VolumeInfo volume_info = CreateDriveVolumeInfo(profile_); | 408 VolumeInfo volume_info = CreateDriveVolumeInfo(profile_); |
406 DoMountEvent(chromeos::MOUNT_ERROR_NONE, volume_info); | 409 DoMountEvent(chromeos::MOUNT_ERROR_NONE, volume_info); |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
815 return; | 818 return; |
816 if (error_code == chromeos::MOUNT_ERROR_NONE) | 819 if (error_code == chromeos::MOUNT_ERROR_NONE) |
817 mounted_volumes_.erase(volume_info.volume_id); | 820 mounted_volumes_.erase(volume_info.volume_id); |
818 | 821 |
819 FOR_EACH_OBSERVER(VolumeManagerObserver, | 822 FOR_EACH_OBSERVER(VolumeManagerObserver, |
820 observers_, | 823 observers_, |
821 OnVolumeUnmounted(error_code, volume_info)); | 824 OnVolumeUnmounted(error_code, volume_info)); |
822 } | 825 } |
823 | 826 |
824 } // namespace file_manager | 827 } // namespace file_manager |
OLD | NEW |