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

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: Addressed comments Created 8 years, 5 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..5bfd269de258c08a439f2a6878bd3a3c61a49792 100644
--- a/chrome/browser/media_gallery/media_device_notifications_chromeos.cc
+++ b/chrome/browser/media_gallery/media_device_notifications_chromeos.cc
@@ -19,12 +19,23 @@ 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,
Lei Zhang 2012/08/03 05:45:25 |device_id_str| -> |device_id| here and below.
kmadhusu 2012/08/03 06:07:11 Done.
+ string16* 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;
Lei Zhang 2012/08/03 05:45:25 May want to return bool, so the caller knows |devi
kmadhusu 2012/08/03 06:07:11 Done.
+
+ const disks::DiskMountManager::Disk& disk = *(it->second);
+ *device_id_str = disk.fs_uuid();
+
+ // TODO(kmadhusu): If device label is empty, extract vendor and model details
+ // and use them as device_label.
+ *device_label = disk.device_label().empty() ?
Lei Zhang 2012/08/03 05:45:25 Would UTF8ToUTF16(foo ? bar : qux) be better?
kmadhusu 2012/08/03 06:07:11 Done.
+ UTF8ToUTF16(FilePath(source_path).BaseName().value()) :
+ UTF8ToUTF16(disk.device_label());
}
} // namespace
@@ -114,8 +125,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;
+ string16 device_label;
+ 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 +139,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()),
+ 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