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

Unified Diff: chrome/browser/media/media_stream_devices_menu_model.cc

Issue 10912004: Begin adding support for tab mirroring via the MediaStream audio/video capturing (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Simplify: Use only one AudioInputDeviceManager and VideoCaptureManager, like before. Created 8 years, 3 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/media/media_stream_devices_menu_model.cc
diff --git a/chrome/browser/media/media_stream_devices_menu_model.cc b/chrome/browser/media/media_stream_devices_menu_model.cc
index 423af47a1a4867928bb1f8bd954e9c833807ddcf..3da1eb6e08ca7ac216119216a6a3b2782dc9e293 100644
--- a/chrome/browser/media/media_stream_devices_menu_model.cc
+++ b/chrome/browser/media/media_stream_devices_menu_model.cc
@@ -6,6 +6,7 @@
#include <utility>
+#include "base/logging.h"
#include "base/utf_string_conversions.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/ui/media_stream_infobar_delegate.h"
@@ -17,20 +18,20 @@ MediaStreamDevicesMenuModel::MediaStreamDevicesMenuModel(
MediaStreamInfoBarDelegate* delegate)
: ALLOW_THIS_IN_INITIALIZER_LIST(ui::SimpleMenuModel(this)),
media_stream_delegate_(delegate) {
- bool audio = delegate->HasAudio() && !delegate->GetAudioDevices().empty();
- bool video = delegate->HasVideo() && !delegate->GetVideoDevices().empty();
- if (video) {
+ if (delegate->HasVideo()) {
AddDevices(delegate->GetVideoDevices());
- if (audio)
+ if (delegate->HasAudio()) {
AddSeparator(ui::NORMAL_SEPARATOR);
+ }
}
- if (audio) {
+ if (delegate->HasAudio()) {
AddDevices(delegate->GetAudioDevices());
}
- // Show "always allow" option only for the secure connection.
- if (delegate->GetSecurityOrigin().SchemeIsSecure())
- AddAlwaysAllowOption(audio, video);
+ // Show "always allow" option when auto-accepting would be safe in the future.
+ AddAlwaysAllowOption(
+ delegate->HasAudio() && delegate->IsSafeToAlwaysAllowAudio(),
+ delegate->HasVideo() && delegate->IsSafeToAlwaysAllowVideo());
}
MediaStreamDevicesMenuModel::~MediaStreamDevicesMenuModel() {
@@ -66,10 +67,13 @@ void MediaStreamDevicesMenuModel::ExecuteCommand(int command_id) {
CommandMap::const_iterator it = commands_.find(command_id);
DCHECK(it != commands_.end());
- if (it->second.type == content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE)
+ if (content::IsAudioMediaType(it->second.type)) {
media_stream_delegate_->set_selected_audio_device(it->second.device_id);
- else
+ } else if (content::IsVideoMediaType(it->second.type)) {
media_stream_delegate_->set_selected_video_device(it->second.device_id);
+ } else {
+ NOTREACHED();
+ }
}
void MediaStreamDevicesMenuModel::AddDevices(
@@ -77,9 +81,15 @@ void MediaStreamDevicesMenuModel::AddDevices(
for (size_t i = 0; i < devices.size(); ++i) {
int command_id = commands_.size();
commands_.insert(std::make_pair(command_id, devices[i]));
- int message_id = (devices[i].type ==
- content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE) ?
- IDS_MEDIA_CAPTURE_AUDIO : IDS_MEDIA_CAPTURE_VIDEO;
+ int message_id;
+ if (content::IsAudioMediaType(devices[i].type)) {
+ message_id = IDS_MEDIA_CAPTURE_AUDIO;
+ } else if (content::IsVideoMediaType(devices[i].type)) {
+ message_id = IDS_MEDIA_CAPTURE_VIDEO;
+ } else {
+ NOTIMPLEMENTED();
+ continue;
+ }
AddCheckItem(command_id,
l10n_util::GetStringFUTF16(message_id,
UTF8ToUTF16(devices[i].name)));
@@ -87,6 +97,10 @@ void MediaStreamDevicesMenuModel::AddDevices(
}
void MediaStreamDevicesMenuModel::AddAlwaysAllowOption(bool audio, bool video) {
+ if (!audio && !video) {
tommi (sloooow) - chröme 2012/09/10 09:17:25 no {}
miu 2012/09/10 21:24:38 Done.
+ return;
+ }
+
int command_id = IDC_MEDIA_STREAM_DEVICE_ALWAYS_ALLOW;
int message_id = IDS_MEDIA_CAPTURE_ALWAYS_ALLOW_AUDIO_AND_VIDEO;
if (audio && !video)

Powered by Google App Engine
This is Rietveld 408576698