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 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
654 for (int i = 2; mounted_volumes_.count(kMtpVolumeIdPrefix + label); ++i) | 654 for (int i = 2; mounted_volumes_.count(kMtpVolumeIdPrefix + label); ++i) |
655 label = base_name + base::StringPrintf(" (%d)", i); | 655 label = base_name + base::StringPrintf(" (%d)", i); |
656 | 656 |
657 bool result = | 657 bool result = |
658 storage::ExternalMountPoints::GetSystemInstance()->RegisterFileSystem( | 658 storage::ExternalMountPoints::GetSystemInstance()->RegisterFileSystem( |
659 fsid, | 659 fsid, |
660 storage::kFileSystemTypeDeviceMediaAsFileStorage, | 660 storage::kFileSystemTypeDeviceMediaAsFileStorage, |
661 storage::FileSystemMountOption(), | 661 storage::FileSystemMountOption(), |
662 path); | 662 path); |
663 DCHECK(result); | 663 DCHECK(result); |
| 664 |
| 665 // TODO(yawano) A variable to switch MTP write support. This variable should |
| 666 // be false until MTP write operation is implemented and shipped. |
| 667 bool write_supported = false; |
| 668 |
664 content::BrowserThread::PostTask( | 669 content::BrowserThread::PostTask( |
665 content::BrowserThread::IO, FROM_HERE, base::Bind( | 670 content::BrowserThread::IO, FROM_HERE, |
666 &MTPDeviceMapService::RegisterMTPFileSystem, | 671 base::Bind(&MTPDeviceMapService::RegisterMTPFileSystem, |
667 base::Unretained(MTPDeviceMapService::GetInstance()), | 672 base::Unretained(MTPDeviceMapService::GetInstance()), |
668 info.location(), fsid)); | 673 info.location(), fsid, !write_supported /* read_only */)); |
669 | 674 |
670 VolumeInfo volume_info; | 675 VolumeInfo volume_info; |
671 volume_info.type = VOLUME_TYPE_MTP; | 676 volume_info.type = VOLUME_TYPE_MTP; |
672 volume_info.mount_path = path; | 677 volume_info.mount_path = path; |
673 volume_info.mount_condition = chromeos::disks::MOUNT_CONDITION_NONE; | 678 volume_info.mount_condition = chromeos::disks::MOUNT_CONDITION_NONE; |
674 volume_info.is_parent = true; | 679 volume_info.is_parent = true; |
675 volume_info.is_read_only = true; | 680 volume_info.is_read_only = !write_supported; |
676 volume_info.volume_id = kMtpVolumeIdPrefix + label; | 681 volume_info.volume_id = kMtpVolumeIdPrefix + label; |
677 volume_info.volume_label = label; | 682 volume_info.volume_label = label; |
678 volume_info.source_path = path; | 683 volume_info.source_path = path; |
679 volume_info.device_type = chromeos::DEVICE_TYPE_MOBILE; | 684 volume_info.device_type = chromeos::DEVICE_TYPE_MOBILE; |
680 DoMountEvent(chromeos::MOUNT_ERROR_NONE, volume_info); | 685 DoMountEvent(chromeos::MOUNT_ERROR_NONE, volume_info); |
681 } | 686 } |
682 | 687 |
683 void VolumeManager::OnRemovableStorageDetached( | 688 void VolumeManager::OnRemovableStorageDetached( |
684 const storage_monitor::StorageInfo& info) { | 689 const storage_monitor::StorageInfo& info) { |
685 if (!storage_monitor::StorageInfo::IsMTPDevice(info.device_id())) | 690 if (!storage_monitor::StorageInfo::IsMTPDevice(info.device_id())) |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
810 return; | 815 return; |
811 if (error_code == chromeos::MOUNT_ERROR_NONE) | 816 if (error_code == chromeos::MOUNT_ERROR_NONE) |
812 mounted_volumes_.erase(volume_info.volume_id); | 817 mounted_volumes_.erase(volume_info.volume_id); |
813 | 818 |
814 FOR_EACH_OBSERVER(VolumeManagerObserver, | 819 FOR_EACH_OBSERVER(VolumeManagerObserver, |
815 observers_, | 820 observers_, |
816 OnVolumeUnmounted(error_code, volume_info)); | 821 OnVolumeUnmounted(error_code, volume_info)); |
817 } | 822 } |
818 | 823 |
819 } // namespace file_manager | 824 } // namespace file_manager |
OLD | NEW |