| 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 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 DoMountEvent(chromeos::MOUNT_ERROR_NONE, volume); | 364 DoMountEvent(chromeos::MOUNT_ERROR_NONE, volume); |
| 365 } | 365 } |
| 366 } | 366 } |
| 367 | 367 |
| 368 // Subscribe to Profile Preference change. | 368 // Subscribe to Profile Preference change. |
| 369 pref_change_registrar_.Init(profile_->GetPrefs()); | 369 pref_change_registrar_.Init(profile_->GetPrefs()); |
| 370 pref_change_registrar_.Add( | 370 pref_change_registrar_.Add( |
| 371 prefs::kExternalStorageDisabled, | 371 prefs::kExternalStorageDisabled, |
| 372 base::Bind(&VolumeManager::OnExternalStorageDisabledChanged, | 372 base::Bind(&VolumeManager::OnExternalStorageDisabledChanged, |
| 373 weak_ptr_factory_.GetWeakPtr())); | 373 weak_ptr_factory_.GetWeakPtr())); |
| 374 pref_change_registrar_.Add( |
| 375 prefs::kExternalStorageReadOnly, |
| 376 base::Bind(&VolumeManager::OnExternalStorageReadOnlyChanged, |
| 377 weak_ptr_factory_.GetWeakPtr())); |
| 374 | 378 |
| 375 // Subscribe to storage monitor for MTP notifications. | 379 // Subscribe to storage monitor for MTP notifications. |
| 376 if (storage_monitor::StorageMonitor::GetInstance()) { | 380 if (storage_monitor::StorageMonitor::GetInstance()) { |
| 377 storage_monitor::StorageMonitor::GetInstance()->EnsureInitialized( | 381 storage_monitor::StorageMonitor::GetInstance()->EnsureInitialized( |
| 378 base::Bind(&VolumeManager::OnStorageMonitorInitialized, | 382 base::Bind(&VolumeManager::OnStorageMonitorInitialized, |
| 379 weak_ptr_factory_.GetWeakPtr())); | 383 weak_ptr_factory_.GetWeakPtr())); |
| 380 } | 384 } |
| 381 } | 385 } |
| 382 | 386 |
| 383 void VolumeManager::Shutdown() { | 387 void VolumeManager::Shutdown() { |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 711 const std::string& mount_path = | 715 const std::string& mount_path = |
| 712 disk_mount_manager_->mount_points().begin()->second.mount_path; | 716 disk_mount_manager_->mount_points().begin()->second.mount_path; |
| 713 disk_mount_manager_->UnmountPath( | 717 disk_mount_manager_->UnmountPath( |
| 714 mount_path, chromeos::UNMOUNT_OPTIONS_NONE, | 718 mount_path, chromeos::UNMOUNT_OPTIONS_NONE, |
| 715 base::Bind( | 719 base::Bind( |
| 716 &VolumeManager::OnExternalStorageDisabledChangedUnmountCallback, | 720 &VolumeManager::OnExternalStorageDisabledChangedUnmountCallback, |
| 717 weak_ptr_factory_.GetWeakPtr())); | 721 weak_ptr_factory_.GetWeakPtr())); |
| 718 } | 722 } |
| 719 } | 723 } |
| 720 | 724 |
| 725 void VolumeManager::OnExternalStorageReadOnlyChanged() { |
| 726 disk_mount_manager_->RemountAllRemovableDrives( |
| 727 GetExternalStorageAccessMode(profile_)); |
| 728 } |
| 729 |
| 721 void VolumeManager::OnRemovableStorageAttached( | 730 void VolumeManager::OnRemovableStorageAttached( |
| 722 const storage_monitor::StorageInfo& info) { | 731 const storage_monitor::StorageInfo& info) { |
| 723 if (!storage_monitor::StorageInfo::IsMTPDevice(info.device_id())) | 732 if (!storage_monitor::StorageInfo::IsMTPDevice(info.device_id())) |
| 724 return; | 733 return; |
| 725 if (profile_->GetPrefs()->GetBoolean(prefs::kExternalStorageDisabled)) | 734 if (profile_->GetPrefs()->GetBoolean(prefs::kExternalStorageDisabled)) |
| 726 return; | 735 return; |
| 727 | 736 |
| 728 const base::FilePath path = base::FilePath::FromUTF8Unsafe(info.location()); | 737 const base::FilePath path = base::FilePath::FromUTF8Unsafe(info.location()); |
| 729 const std::string fsid = GetMountPointNameForMediaStorage(info); | 738 const std::string fsid = GetMountPointNameForMediaStorage(info); |
| 730 const std::string base_name = base::UTF16ToUTF8(info.model_name()); | 739 const std::string base_name = base::UTF16ToUTF8(info.model_name()); |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 904 if (mounted_volumes_.find(volume->volume_id()) == mounted_volumes_.end()) | 913 if (mounted_volumes_.find(volume->volume_id()) == mounted_volumes_.end()) |
| 905 return; | 914 return; |
| 906 if (error_code == chromeos::MOUNT_ERROR_NONE) | 915 if (error_code == chromeos::MOUNT_ERROR_NONE) |
| 907 mounted_volumes_.erase(volume->volume_id()); | 916 mounted_volumes_.erase(volume->volume_id()); |
| 908 | 917 |
| 909 for (auto& observer : observers_) | 918 for (auto& observer : observers_) |
| 910 observer.OnVolumeUnmounted(error_code, *volume.get()); | 919 observer.OnVolumeUnmounted(error_code, *volume.get()); |
| 911 } | 920 } |
| 912 | 921 |
| 913 } // namespace file_manager | 922 } // namespace file_manager |
| OLD | NEW |