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

Unified Diff: chrome/browser/ui/webui/options/media_devices_selection_handler.cc

Issue 2703393007: Show meaningful name for cameras (Closed)
Patch Set: Moved to chrome/browser/ui/webui/ Created 3 years, 10 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
Index: chrome/browser/ui/webui/options/media_devices_selection_handler.cc
diff --git a/chrome/browser/ui/webui/options/media_devices_selection_handler.cc b/chrome/browser/ui/webui/options/media_devices_selection_handler.cc
index cb5009b15215ceb27225ae6385ea18147f380cb6..d07056b925d8c693190f46f0b2a61d7e72409459 100644
--- a/chrome/browser/ui/webui/options/media_devices_selection_handler.cc
+++ b/chrome/browser/ui/webui/options/media_devices_selection_handler.cc
@@ -15,6 +15,8 @@
#include "chrome/common/pref_names.h"
#include "chrome/grit/generated_resources.h"
#include "components/prefs/pref_service.h"
+#include "extensions/strings/grit/extensions_strings.h"
+#include "ui/base/l10n/l10n_util.h"
namespace {
@@ -113,7 +115,7 @@ void MediaDevicesSelectionHandler::UpdateDevicesMenu(
base::ListValue device_list;
for (size_t i = 0; i < devices.size(); ++i) {
std::unique_ptr<base::DictionaryValue> entry(new base::DictionaryValue());
- entry->SetString("name", devices[i].name);
+ entry->SetString("name", GetDeviceDisplayName(devices[i]));
entry->SetString("id", devices[i].id);
device_list.Append(std::move(entry));
if (devices[i].id == default_device)
@@ -132,6 +134,26 @@ void MediaDevicesSelectionHandler::UpdateDevicesMenu(
default_value);
}
+std::string MediaDevicesSelectionHandler::GetDeviceDisplayName(
+ const content::MediaStreamDevice& device) {
+ std::string facing_info;
+ switch (device.video_facing) {
+ case media::VideoFacingMode::MEDIA_VIDEO_FACING_USER:
+ facing_info = l10n_util::GetStringUTF8(IDS_CAMERA_FACING_USER);
+ break;
+ case media::VideoFacingMode::MEDIA_VIDEO_FACING_ENVIRONMENT:
+ facing_info = l10n_util::GetStringUTF8(IDS_CAMERA_FACING_ENVIRONMENT);
+ break;
+ case media::VideoFacingMode::MEDIA_VIDEO_FACING_NONE:
+ case media::VideoFacingMode::NUM_MEDIA_VIDEO_FACING_MODES:
mtomasz 2017/03/02 07:49:53 nit: Add NOTREACHED()?
shenghao 2017/03/02 12:43:41 MEDIA_VIDEO_FACING_NONE is possible. I added NOTRE
+ break;
+ }
+
+ if (facing_info.empty())
+ return device.name;
+ return device.name + " (" + facing_info + ")";
mtomasz 2017/03/02 07:49:53 This may provide broken strings in some languages,
shenghao 2017/03/02 12:43:41 I would just delete the brackets.
+}
+
void MediaDevicesSelectionHandler::UpdateDevicesMenuForType(DeviceType type) {
content::MediaStreamDevices devices;
switch (type) {

Powered by Google App Engine
This is Rietveld 408576698