| Index: chrome/browser/system_monitor/removable_device_notifications_chromeos.cc
|
| diff --git a/chrome/browser/system_monitor/removable_device_notifications_chromeos.cc b/chrome/browser/system_monitor/removable_device_notifications_chromeos.cc
|
| index 14b533089d584dbf2538d99bed175497eb849b1a..deac4ce3f2e5575bf3e08aa814e2d95e34e78100 100644
|
| --- a/chrome/browser/system_monitor/removable_device_notifications_chromeos.cc
|
| +++ b/chrome/browser/system_monitor/removable_device_notifications_chromeos.cc
|
| @@ -23,7 +23,10 @@ namespace {
|
|
|
| // Constructs a device name using label or manufacturer (vendor and product)
|
| // name details.
|
| -string16 GetDeviceName(const disks::DiskMountManager::Disk& disk) {
|
| +string16 GetDeviceName(const disks::DiskMountManager::Disk& disk,
|
| + string16* storage_label,
|
| + string16* vendor_name,
|
| + string16* model_name) {
|
| if (disk.device_type() == DEVICE_TYPE_SD) {
|
| // Mount path of an SD card will be one of the following:
|
| // (1) /media/removable/<volume_label>
|
| @@ -36,8 +39,17 @@ string16 GetDeviceName(const disks::DiskMountManager::Disk& disk) {
|
| }
|
|
|
| const std::string& device_label = disk.device_label();
|
| +
|
| + if (storage_label)
|
| + *storage_label = UTF8ToUTF16(device_label);
|
| + if (vendor_name)
|
| + *vendor_name = UTF8ToUTF16(disk.vendor_name());
|
| + if (model_name)
|
| + *model_name = UTF8ToUTF16(disk.product_name());
|
| +
|
| if (!device_label.empty() && IsStringUTF8(device_label))
|
| return UTF8ToUTF16(device_label);
|
| +
|
| return chrome::GetFullProductName(disk.vendor_name(), disk.product_name());
|
| }
|
|
|
| @@ -65,7 +77,10 @@ std::string MakeDeviceUniqueId(const disks::DiskMountManager::Disk& disk) {
|
| bool GetDeviceInfo(const std::string& source_path,
|
| std::string* unique_id,
|
| string16* device_label,
|
| - uint64* storage_size_in_bytes) {
|
| + uint64* storage_size_in_bytes,
|
| + string16* storage_label,
|
| + string16* vendor_name,
|
| + string16* model_name) {
|
| const disks::DiskMountManager::Disk* disk =
|
| disks::DiskMountManager::GetInstance()->FindDiskBySourcePath(source_path);
|
| if (!disk || disk->device_type() == DEVICE_TYPE_UNKNOWN)
|
| @@ -75,7 +90,7 @@ bool GetDeviceInfo(const std::string& source_path,
|
| *unique_id = MakeDeviceUniqueId(*disk);
|
|
|
| if (device_label)
|
| - *device_label = GetDeviceName(*disk);
|
| + *device_label = GetDeviceName(*disk, storage_label, vendor_name, model_name);
|
|
|
| if (storage_size_in_bytes)
|
| *storage_size_in_bytes = disk->total_size_in_bytes();
|
| @@ -156,7 +171,7 @@ void RemovableDeviceNotificationsCros::OnMountEvent(
|
| MountMap::iterator it = mount_map_.find(mount_info.mount_path);
|
| if (it == mount_map_.end())
|
| return;
|
| - receiver()->ProcessDetach(it->second.storage_info.device_id);
|
| + receiver()->ProcessDetach(it->second.device_id);
|
| mount_map_.erase(it);
|
| break;
|
| }
|
| @@ -186,7 +201,7 @@ bool RemovableDeviceNotificationsCros::GetDeviceInfoForPath(
|
| return false;
|
|
|
| if (device_info)
|
| - *device_info = info_it->second.storage_info;
|
| + *device_info = info_it->second;
|
| return true;
|
| }
|
|
|
| @@ -194,7 +209,7 @@ uint64 RemovableDeviceNotificationsCros::GetStorageSize(
|
| const std::string& device_location) const {
|
| MountMap::const_iterator info_it = mount_map_.find(device_location);
|
| return (info_it != mount_map_.end()) ?
|
| - info_it->second.storage_size_in_bytes : 0;
|
| + info_it->second.total_size_in_bytes : 0;
|
| }
|
|
|
| void RemovableDeviceNotificationsCros::CheckMountedPathOnFileThread(
|
| @@ -223,9 +238,13 @@ void RemovableDeviceNotificationsCros::AddMountedPathOnUIThread(
|
| // Get the media device uuid and label if exists.
|
| std::string unique_id;
|
| string16 device_label;
|
| + string16 storage_label;
|
| + string16 vendor_name;
|
| + string16 model_name;
|
| uint64 storage_size_in_bytes;
|
| if (!GetDeviceInfo(mount_info.source_path, &unique_id, &device_label,
|
| - &storage_size_in_bytes))
|
| + &storage_size_in_bytes, &storage_label,
|
| + &vendor_name, &model_name))
|
| return;
|
|
|
| // Keep track of device uuid and label, to see how often we receive empty
|
| @@ -241,15 +260,21 @@ void RemovableDeviceNotificationsCros::AddMountedPathOnUIThread(
|
|
|
| std::string device_id = chrome::MediaStorageUtil::MakeDeviceId(type,
|
| unique_id);
|
| - StorageObjectInfo object_info = {
|
| - StorageInfo(device_id, device_label, mount_info.mount_path),
|
| - storage_size_in_bytes
|
| - };
|
| - mount_map_.insert(std::make_pair(mount_info.mount_path, object_info));
|
| - receiver()->ProcessAttach(
|
| + StorageInfo object_info(
|
| device_id,
|
| chrome::GetDisplayNameForDevice(storage_size_in_bytes, device_label),
|
| mount_info.mount_path);
|
| + object_info.total_size_in_bytes = storage_size_in_bytes;
|
| + object_info.device_type = has_dcim ?
|
| + chrome::MediaStorageUtil::REMOVABLE_MASS_STORAGE_WITH_DCIM :
|
| + chrome::MediaStorageUtil::REMOVABLE_MASS_STORAGE_NO_DCIM;
|
| + object_info.storage_label = storage_label;
|
| + object_info.vendor_name = vendor_name;
|
| + object_info.model_name = model_name;
|
| +
|
| + mount_map_.insert(std::make_pair(mount_info.mount_path, object_info));
|
| +
|
| + receiver()->ProcessAttach(object_info);
|
| }
|
|
|
| } // namespace chromeos
|
|
|