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

Unified Diff: chrome/browser/media_gallery/media_device_notifications_chromeos.cc

Issue 10826135: Use mounted device label as name in media device notification message. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added TODO Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
}
« 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