Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(597)

Side by Side Diff: chrome/browser/chromeos/file_manager/volume_manager.cc

Issue 305053004: Use .volume_label property for notifying MTP volume labels. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/callback.h" 9 #include "base/callback.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 if (!storage_monitor::StorageInfo::IsMTPDevice(info.device_id())) 722 if (!storage_monitor::StorageInfo::IsMTPDevice(info.device_id()))
723 return; 723 return;
724 if (profile_->GetPrefs()->GetBoolean(prefs::kExternalStorageDisabled)) 724 if (profile_->GetPrefs()->GetBoolean(prefs::kExternalStorageDisabled))
725 return; 725 return;
726 726
727 const base::FilePath path = base::FilePath::FromUTF8Unsafe(info.location()); 727 const base::FilePath path = base::FilePath::FromUTF8Unsafe(info.location());
728 const std::string fsid = GetMountPointNameForMediaStorage(info); 728 const std::string fsid = GetMountPointNameForMediaStorage(info);
729 const std::string base_name = base::UTF16ToUTF8(info.model_name()); 729 const std::string base_name = base::UTF16ToUTF8(info.model_name());
730 730
731 // Assign a fresh volume ID based on the volume name. 731 // Assign a fresh volume ID based on the volume name.
732 std::string id = kMtpVolumeIdPrefix + base_name; 732 std::string label = base_name;
733 for (int i = 2; mounted_volumes_.count(id); ++i) 733 for (int i = 2; mounted_volumes_.count(kMtpVolumeIdPrefix + label); ++i)
734 id = kMtpVolumeIdPrefix + base_name + base::StringPrintf(" (%d)", i); 734 label = base_name + base::StringPrintf(" (%d)", i);
735 735
736 bool result = 736 bool result =
737 fileapi::ExternalMountPoints::GetSystemInstance()->RegisterFileSystem( 737 fileapi::ExternalMountPoints::GetSystemInstance()->RegisterFileSystem(
738 fsid, fileapi::kFileSystemTypeDeviceMediaAsFileStorage, 738 fsid, fileapi::kFileSystemTypeDeviceMediaAsFileStorage,
739 fileapi::FileSystemMountOption(), path); 739 fileapi::FileSystemMountOption(), path);
740 DCHECK(result); 740 DCHECK(result);
741 content::BrowserThread::PostTask( 741 content::BrowserThread::PostTask(
742 content::BrowserThread::IO, FROM_HERE, base::Bind( 742 content::BrowserThread::IO, FROM_HERE, base::Bind(
743 &MTPDeviceMapService::RegisterMTPFileSystem, 743 &MTPDeviceMapService::RegisterMTPFileSystem,
744 base::Unretained(MTPDeviceMapService::GetInstance()), 744 base::Unretained(MTPDeviceMapService::GetInstance()),
745 info.location(), fsid)); 745 info.location(), fsid));
746 746
747 VolumeInfo volume_info; 747 VolumeInfo volume_info;
748 volume_info.type = VOLUME_TYPE_MTP; 748 volume_info.type = VOLUME_TYPE_MTP;
749 volume_info.mount_path = path; 749 volume_info.mount_path = path;
750 volume_info.mount_condition = chromeos::disks::MOUNT_CONDITION_NONE; 750 volume_info.mount_condition = chromeos::disks::MOUNT_CONDITION_NONE;
751 volume_info.is_parent = true; 751 volume_info.is_parent = true;
752 volume_info.is_read_only = true; 752 volume_info.is_read_only = true;
753 volume_info.volume_id = id; 753 volume_info.volume_id = kMtpVolumeIdPrefix + label;
754 volume_info.volume_label = label;
754 volume_info.source_path = path; 755 volume_info.source_path = path;
755 volume_info.device_type = chromeos::DEVICE_TYPE_MOBILE; 756 volume_info.device_type = chromeos::DEVICE_TYPE_MOBILE;
756 DoMountEvent(chromeos::MOUNT_ERROR_NONE, volume_info, false); 757 DoMountEvent(chromeos::MOUNT_ERROR_NONE, volume_info, false);
757 } 758 }
758 759
759 void VolumeManager::OnRemovableStorageDetached( 760 void VolumeManager::OnRemovableStorageDetached(
760 const storage_monitor::StorageInfo& info) { 761 const storage_monitor::StorageInfo& info) {
761 if (!storage_monitor::StorageInfo::IsMTPDevice(info.device_id())) 762 if (!storage_monitor::StorageInfo::IsMTPDevice(info.device_id()))
762 return; 763 return;
763 764
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 return; 837 return;
837 if (error_code == chromeos::MOUNT_ERROR_NONE) 838 if (error_code == chromeos::MOUNT_ERROR_NONE)
838 mounted_volumes_.erase(volume_info.volume_id); 839 mounted_volumes_.erase(volume_info.volume_id);
839 840
840 FOR_EACH_OBSERVER(VolumeManagerObserver, 841 FOR_EACH_OBSERVER(VolumeManagerObserver,
841 observers_, 842 observers_,
842 OnVolumeUnmounted(error_code, volume_info)); 843 OnVolumeUnmounted(error_code, volume_info));
843 } 844 }
844 845
845 } // namespace file_manager 846 } // namespace file_manager
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698