Index: chrome/browser/media_gallery/media_device_notifications_chromeos.cc |
diff --git a/chrome/browser/media_gallery/media_device_notifications_chromeos.cc b/chrome/browser/media_gallery/media_device_notifications_chromeos.cc |
index f8bb783faee3b50d9487b42f756a8025b1451759..eabf40d2e0e5997ef5c08a996182ed22d3f44de0 100644 |
--- a/chrome/browser/media_gallery/media_device_notifications_chromeos.cc |
+++ b/chrome/browser/media_gallery/media_device_notifications_chromeos.cc |
@@ -19,12 +19,20 @@ namespace chromeos { |
namespace { |
-std::string GetDeviceUuid(const std::string& source_path) { |
- // Get the media device uuid if exists. |
+void GetDeviceInfo(const std::string& source_path, std::string* device_id_str, |
+ std::string* device_label) { |
+ // Get the media device uuid and label if exists. |
const disks::DiskMountManager::DiskMap& disks = |
disks::DiskMountManager::GetInstance()->disks(); |
disks::DiskMountManager::DiskMap::const_iterator it = disks.find(source_path); |
- return it == disks.end() ? std::string() : it->second->fs_uuid(); |
+ if (it == disks.end()) |
+ return; |
+ *device_id_str = it->second->fs_uuid(); |
Lei Zhang
2012/08/03 01:44:03
The code here and below may be more readable if yo
kmadhusu
2012/08/03 05:22:37
Done.
|
+ // TODO(kmadhusu): If device label is empty, extract vendor and model detail |
+ // from udevadm and use them as device_label. |
Lei Zhang
2012/08/03 02:05:51
You shouldn't have to use udevadm as a workaround.
kmadhusu
2012/08/03 05:22:37
sure. Modified TODO comment.
|
+ *device_label = it->second->device_label().empty() ? |
+ FilePath(source_path).BaseName().value() : |
+ it->second->device_label(); |
} |
} // namespace |
@@ -114,8 +122,10 @@ void MediaDeviceNotifications::AddMountedPathOnUIThread( |
return; |
} |
- // Get the media device uuid if exists. |
- std::string device_id_str = GetDeviceUuid(mount_info.source_path); |
+ // Get the media device uuid and label if exists. |
+ std::string device_id_str; |
+ std::string device_label; |
Lei Zhang
2012/08/03 01:44:03
just make this a string16 and do the conversion in
kmadhusu
2012/08/03 05:22:37
Done.
|
+ GetDeviceInfo(mount_info.source_path, &device_id_str, &device_label); |
// Keep track of device uuid, to see how often we receive empty uuid values. |
UMA_HISTOGRAM_BOOLEAN("MediaDeviceNotification.device_uuid_available", |
@@ -126,7 +136,7 @@ void MediaDeviceNotifications::AddMountedPathOnUIThread( |
mount_map_.insert(std::make_pair(mount_info.mount_path, device_id_str)); |
base::SystemMonitor::Get()->ProcessMediaDeviceAttached( |
device_id_str, |
- UTF8ToUTF16(FilePath(mount_info.source_path).BaseName().value()), |
+ UTF8ToUTF16(device_label), |
base::SystemMonitor::TYPE_PATH, |
mount_info.mount_path); |
} |