Chromium Code Reviews| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 128 volume.mount_path().BaseName().AsUTF8Unsafe()); | 128 volume.mount_path().BaseName().AsUTF8Unsafe()); |
| 129 } | 129 } |
| 130 | 130 |
| 131 std::string GetMountPointNameForMediaStorage( | 131 std::string GetMountPointNameForMediaStorage( |
| 132 const storage_monitor::StorageInfo& info) { | 132 const storage_monitor::StorageInfo& info) { |
| 133 std::string name(kFileManagerMTPMountNamePrefix); | 133 std::string name(kFileManagerMTPMountNamePrefix); |
| 134 name += info.device_id(); | 134 name += info.device_id(); |
| 135 return name; | 135 return name; |
| 136 } | 136 } |
| 137 | 137 |
| 138 chromeos::MountAccessMode GetExternalStorageAccessMode(const Profile* profile) { | |
| 139 bool read_only = | |
| 140 profile->GetPrefs()->HasPrefPath(prefs::kExternalStorageReadOnly) | |
|
yamaguchi
2016/08/05 06:14:44
Reverted this check in Patch Set 8 because Has*()
| |
| 141 ? profile->GetPrefs()->GetBoolean(prefs::kExternalStorageReadOnly) | |
| 142 : false; | |
| 143 return read_only ? chromeos::MOUNT_ACCESS_MODE_READ_ONLY | |
| 144 : chromeos::MOUNT_ACCESS_MODE_READ_WRITE; | |
| 145 } | |
| 146 | |
| 138 } // namespace | 147 } // namespace |
| 139 | 148 |
| 140 Volume::Volume() | 149 Volume::Volume() |
| 141 : source_(SOURCE_FILE), | 150 : source_(SOURCE_FILE), |
| 142 type_(VOLUME_TYPE_GOOGLE_DRIVE), | 151 type_(VOLUME_TYPE_GOOGLE_DRIVE), |
| 143 device_type_(chromeos::DEVICE_TYPE_UNKNOWN), | 152 device_type_(chromeos::DEVICE_TYPE_UNKNOWN), |
| 144 mount_condition_(chromeos::disks::MOUNT_CONDITION_NONE), | 153 mount_condition_(chromeos::disks::MOUNT_CONDITION_NONE), |
| 145 mount_context_(MOUNT_CONTEXT_UNKNOWN), | 154 mount_context_(MOUNT_CONTEXT_UNKNOWN), |
| 146 is_parent_(false), | 155 is_parent_(false), |
| 147 is_read_only_(false), | 156 is_read_only_(false), |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 487 } | 496 } |
| 488 | 497 |
| 489 bool mounting = false; | 498 bool mounting = false; |
| 490 if (disk->mount_path().empty() && disk->has_media() && | 499 if (disk->mount_path().empty() && disk->has_media() && |
| 491 !profile_->GetPrefs()->GetBoolean(prefs::kExternalStorageDisabled)) { | 500 !profile_->GetPrefs()->GetBoolean(prefs::kExternalStorageDisabled)) { |
| 492 // If disk is not mounted yet and it has media and there is no policy | 501 // If disk is not mounted yet and it has media and there is no policy |
| 493 // forbidding external storage, give it a try. | 502 // forbidding external storage, give it a try. |
| 494 // Initiate disk mount operation. MountPath auto-detects the filesystem | 503 // Initiate disk mount operation. MountPath auto-detects the filesystem |
| 495 // format if the second argument is empty. The third argument (mount | 504 // format if the second argument is empty. The third argument (mount |
| 496 // label) is not used in a disk mount operation. | 505 // label) is not used in a disk mount operation. |
| 497 disk_mount_manager_->MountPath( | 506 disk_mount_manager_->MountPath(disk->device_path(), std::string(), |
| 498 disk->device_path(), std::string(), std::string(), | 507 std::string(), |
| 499 chromeos::MOUNT_TYPE_DEVICE); | 508 chromeos::MOUNT_TYPE_DEVICE, |
| 509 GetExternalStorageAccessMode(profile_)); | |
| 500 mounting = true; | 510 mounting = true; |
| 501 } | 511 } |
| 502 | 512 |
| 503 // Notify to observers. | 513 // Notify to observers. |
| 504 FOR_EACH_OBSERVER(VolumeManagerObserver, observers_, | 514 FOR_EACH_OBSERVER(VolumeManagerObserver, observers_, |
| 505 OnDiskAdded(*disk, mounting)); | 515 OnDiskAdded(*disk, mounting)); |
| 506 return; | 516 return; |
| 507 } | 517 } |
| 508 | 518 |
| 509 case chromeos::disks::DiskMountManager::DISK_REMOVED: | 519 case chromeos::disks::DiskMountManager::DISK_REMOVED: |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 602 VolumeManagerObserver, observers_, | 612 VolumeManagerObserver, observers_, |
| 603 OnFormatStarted(device_path, | 613 OnFormatStarted(device_path, |
| 604 error_code == chromeos::FORMAT_ERROR_NONE)); | 614 error_code == chromeos::FORMAT_ERROR_NONE)); |
| 605 return; | 615 return; |
| 606 case chromeos::disks::DiskMountManager::FORMAT_COMPLETED: | 616 case chromeos::disks::DiskMountManager::FORMAT_COMPLETED: |
| 607 if (error_code == chromeos::FORMAT_ERROR_NONE) { | 617 if (error_code == chromeos::FORMAT_ERROR_NONE) { |
| 608 // If format is completed successfully, try to mount the device. | 618 // If format is completed successfully, try to mount the device. |
| 609 // MountPath auto-detects filesystem format if second argument is | 619 // MountPath auto-detects filesystem format if second argument is |
| 610 // empty. The third argument (mount label) is not used in a disk mount | 620 // empty. The third argument (mount label) is not used in a disk mount |
| 611 // operation. | 621 // operation. |
| 612 disk_mount_manager_->MountPath( | 622 disk_mount_manager_->MountPath(device_path, std::string(), |
| 613 device_path, std::string(), std::string(), | 623 std::string(), |
| 614 chromeos::MOUNT_TYPE_DEVICE); | 624 chromeos::MOUNT_TYPE_DEVICE, |
| 625 GetExternalStorageAccessMode(profile_)); | |
| 615 } | 626 } |
| 616 | 627 |
| 617 FOR_EACH_OBSERVER( | 628 FOR_EACH_OBSERVER( |
| 618 VolumeManagerObserver, observers_, | 629 VolumeManagerObserver, observers_, |
| 619 OnFormatCompleted(device_path, | 630 OnFormatCompleted(device_path, |
| 620 error_code == chromeos::FORMAT_ERROR_NONE)); | 631 error_code == chromeos::FORMAT_ERROR_NONE)); |
| 621 | 632 |
| 622 return; | 633 return; |
| 623 } | 634 } |
| 624 NOTREACHED(); | 635 NOTREACHED(); |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 875 if (mounted_volumes_.find(volume->volume_id()) == mounted_volumes_.end()) | 886 if (mounted_volumes_.find(volume->volume_id()) == mounted_volumes_.end()) |
| 876 return; | 887 return; |
| 877 if (error_code == chromeos::MOUNT_ERROR_NONE) | 888 if (error_code == chromeos::MOUNT_ERROR_NONE) |
| 878 mounted_volumes_.erase(volume->volume_id()); | 889 mounted_volumes_.erase(volume->volume_id()); |
| 879 | 890 |
| 880 FOR_EACH_OBSERVER(VolumeManagerObserver, observers_, | 891 FOR_EACH_OBSERVER(VolumeManagerObserver, observers_, |
| 881 OnVolumeUnmounted(error_code, *volume.get())); | 892 OnVolumeUnmounted(error_code, *volume.get())); |
| 882 } | 893 } |
| 883 | 894 |
| 884 } // namespace file_manager | 895 } // namespace file_manager |
| OLD | NEW |