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 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 487 } | 487 } |
| 488 | 488 |
| 489 bool mounting = false; | 489 bool mounting = false; |
| 490 if (disk->mount_path().empty() && disk->has_media() && | 490 if (disk->mount_path().empty() && disk->has_media() && |
| 491 !profile_->GetPrefs()->GetBoolean(prefs::kExternalStorageDisabled)) { | 491 !profile_->GetPrefs()->GetBoolean(prefs::kExternalStorageDisabled)) { |
| 492 // If disk is not mounted yet and it has media and there is no policy | 492 // If disk is not mounted yet and it has media and there is no policy |
| 493 // forbidding external storage, give it a try. | 493 // forbidding external storage, give it a try. |
| 494 // Initiate disk mount operation. MountPath auto-detects the filesystem | 494 // Initiate disk mount operation. MountPath auto-detects the filesystem |
| 495 // format if the second argument is empty. The third argument (mount | 495 // format if the second argument is empty. The third argument (mount |
| 496 // label) is not used in a disk mount operation. | 496 // label) is not used in a disk mount operation. |
| 497 | |
|
fukino
2016/08/03 07:18:19
nit: unintentional blank line?
yamaguchi
2016/08/03 10:22:14
Done.
| |
| 497 disk_mount_manager_->MountPath( | 498 disk_mount_manager_->MountPath( |
| 498 disk->device_path(), std::string(), std::string(), | 499 disk->device_path(), std::string(), std::string(), |
| 499 chromeos::MOUNT_TYPE_DEVICE); | 500 chromeos::MOUNT_TYPE_DEVICE, GetExternalStorageAccessMode()); |
| 500 mounting = true; | 501 mounting = true; |
| 501 } | 502 } |
| 502 | 503 |
| 503 // Notify to observers. | 504 // Notify to observers. |
| 504 FOR_EACH_OBSERVER(VolumeManagerObserver, observers_, | 505 FOR_EACH_OBSERVER(VolumeManagerObserver, observers_, |
| 505 OnDiskAdded(*disk, mounting)); | 506 OnDiskAdded(*disk, mounting)); |
| 506 return; | 507 return; |
| 507 } | 508 } |
| 508 | 509 |
| 509 case chromeos::disks::DiskMountManager::DISK_REMOVED: | 510 case chromeos::disks::DiskMountManager::DISK_REMOVED: |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 604 error_code == chromeos::FORMAT_ERROR_NONE)); | 605 error_code == chromeos::FORMAT_ERROR_NONE)); |
| 605 return; | 606 return; |
| 606 case chromeos::disks::DiskMountManager::FORMAT_COMPLETED: | 607 case chromeos::disks::DiskMountManager::FORMAT_COMPLETED: |
| 607 if (error_code == chromeos::FORMAT_ERROR_NONE) { | 608 if (error_code == chromeos::FORMAT_ERROR_NONE) { |
| 608 // If format is completed successfully, try to mount the device. | 609 // If format is completed successfully, try to mount the device. |
| 609 // MountPath auto-detects filesystem format if second argument is | 610 // MountPath auto-detects filesystem format if second argument is |
| 610 // empty. The third argument (mount label) is not used in a disk mount | 611 // empty. The third argument (mount label) is not used in a disk mount |
| 611 // operation. | 612 // operation. |
| 612 disk_mount_manager_->MountPath( | 613 disk_mount_manager_->MountPath( |
| 613 device_path, std::string(), std::string(), | 614 device_path, std::string(), std::string(), |
| 614 chromeos::MOUNT_TYPE_DEVICE); | 615 chromeos::MOUNT_TYPE_DEVICE, GetExternalStorageAccessMode()); |
| 615 } | 616 } |
| 616 | 617 |
| 617 FOR_EACH_OBSERVER( | 618 FOR_EACH_OBSERVER( |
| 618 VolumeManagerObserver, observers_, | 619 VolumeManagerObserver, observers_, |
| 619 OnFormatCompleted(device_path, | 620 OnFormatCompleted(device_path, |
| 620 error_code == chromeos::FORMAT_ERROR_NONE)); | 621 error_code == chromeos::FORMAT_ERROR_NONE)); |
| 621 | 622 |
| 622 return; | 623 return; |
| 623 } | 624 } |
| 624 NOTREACHED(); | 625 NOTREACHED(); |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 874 const linked_ptr<Volume>& volume) { | 875 const linked_ptr<Volume>& volume) { |
| 875 if (mounted_volumes_.find(volume->volume_id()) == mounted_volumes_.end()) | 876 if (mounted_volumes_.find(volume->volume_id()) == mounted_volumes_.end()) |
| 876 return; | 877 return; |
| 877 if (error_code == chromeos::MOUNT_ERROR_NONE) | 878 if (error_code == chromeos::MOUNT_ERROR_NONE) |
| 878 mounted_volumes_.erase(volume->volume_id()); | 879 mounted_volumes_.erase(volume->volume_id()); |
| 879 | 880 |
| 880 FOR_EACH_OBSERVER(VolumeManagerObserver, observers_, | 881 FOR_EACH_OBSERVER(VolumeManagerObserver, observers_, |
| 881 OnVolumeUnmounted(error_code, *volume.get())); | 882 OnVolumeUnmounted(error_code, *volume.get())); |
| 882 } | 883 } |
| 883 | 884 |
| 885 chromeos::MountAccessMode VolumeManager::GetExternalStorageAccessMode() { | |
|
fukino
2016/08/03 07:18:19
This function can be defined under unnamed namespa
yamaguchi
2016/08/03 10:22:14
Done.
| |
| 886 bool read_only = | |
| 887 profile_->GetPrefs()->GetBoolean(prefs::kExternalStorageReadOnly); | |
| 888 return read_only ? chromeos::MOUNT_ACCESS_MODE_READ_ONLY | |
| 889 : chromeos::MOUNT_ACCESS_MODE_READ_WRITE; | |
| 890 } | |
| 891 | |
| 884 } // namespace file_manager | 892 } // namespace file_manager |
| OLD | NEW |