Chromium Code Reviews| Index: chromeos/disks/disk_mount_manager.cc |
| diff --git a/chromeos/disks/disk_mount_manager.cc b/chromeos/disks/disk_mount_manager.cc |
| index 756920ac8c608f7de4a0309f2590d9458b9f811f..c20c79b8ee5f970c16ebe60ba02b110b5c8ee413 100644 |
| --- a/chromeos/disks/disk_mount_manager.cc |
| +++ b/chromeos/disks/disk_mount_manager.cc |
| @@ -87,6 +87,11 @@ class DiskMountManagerImpl : public DiskMountManager { |
| base::Bind(&DiskMountManagerImpl::OnMountCompleted, |
| weak_ptr_factory_.GetWeakPtr(), |
| MountEntry(MOUNT_ERROR_INTERNAL, source_path, type, ""))); |
| + |
| + // Record the access mode option passed to CrosDisks. |
| + // This is needed because CrosDisks service methods doesn't return the info |
| + // via DBus. |
| + access_modes_.insert(std::make_pair(source_path, access_mode)); |
| } |
| // DiskMountManager override. |
| @@ -357,6 +362,15 @@ class DiskMountManagerImpl : public DiskMountManager { |
| } |
| Disk* disk = iter->second; |
| DCHECK(disk); |
| + // The is_read_only field in *disk may be incorrect when this is called |
| + // from CrosDisksClientImpl::OnMountCompleted. |
| + // Overwrite based on the access mode option that was passed when issuing |
| + // mount command to the same mount path last time. |
| + AccessModeMap::iterator it = access_modes_.find(disk->device_path()); |
|
satorux1
2016/08/23 05:40:49
source_path passed to Mount() and disk->device_pat
yamaguchi
2016/08/23 08:08:52
Added comments to the 2 places looking up the map.
|
| + if (it != access_modes_.end()) { |
| + disk->set_read_only(it->second == |
| + chromeos::MOUNT_ACCESS_MODE_READ_ONLY); |
| + } |
| disk->set_mount_path(mount_info.mount_path); |
| } |
| } |
| @@ -473,6 +487,13 @@ class DiskMountManagerImpl : public DiskMountManager { |
| disk_info.on_boot_device(), |
| disk_info.on_removable_device(), |
| disk_info.is_hidden()); |
| + // If the device was mounted by the instance, apply recorded parameter. |
| + AccessModeMap::iterator access_mode = |
|
satorux1
2016/08/23 05:40:49
maybe just call it |iter|?
yamaguchi
2016/08/23 08:08:52
No, because it collides with the one for DiskMap::
|
| + access_modes_.find(disk->device_path()); |
| + if (access_mode != access_modes_.end()) { |
| + disk->set_read_only(access_mode->second == |
| + chromeos::MOUNT_ACCESS_MODE_READ_ONLY); |
| + } |
| disks_.insert(std::make_pair(disk_info.device_path(), disk)); |
| NotifyDiskStatusUpdate(is_new ? DISK_ADDED : DISK_CHANGED, disk); |
| } |
| @@ -640,6 +661,11 @@ class DiskMountManagerImpl : public DiskMountManager { |
| std::unique_ptr<SuspendUnmountManager> suspend_unmount_manager_; |
| + // Whether the instance attempted to mount a device in read-only mode for |
| + // each source path. |
| + typedef std::map<std::string, chromeos::MountAccessMode> AccessModeMap; |
| + AccessModeMap access_modes_; |
| + |
| base::WeakPtrFactory<DiskMountManagerImpl> weak_ptr_factory_; |
| DISALLOW_COPY_AND_ASSIGN(DiskMountManagerImpl); |