Chromium Code Reviews| Index: chrome/browser/content_settings/tab_specific_content_settings.cc |
| diff --git a/chrome/browser/content_settings/tab_specific_content_settings.cc b/chrome/browser/content_settings/tab_specific_content_settings.cc |
| index 013db89cffb495a2205bdaf71dbd0c99ab66db47..49f07e96e0bcbf65a7221543b398e1b90ac8e7ff 100644 |
| --- a/chrome/browser/content_settings/tab_specific_content_settings.cc |
| +++ b/chrome/browser/content_settings/tab_specific_content_settings.cc |
| @@ -530,49 +530,31 @@ bool TabSpecificContentSettings::IsMicrophoneCameraStateChanged() const { |
| void TabSpecificContentSettings::OnMediaStreamPermissionSet( |
| const GURL& request_origin, |
| - const MediaStreamDevicesController::MediaStreamTypeSettingsMap& |
| - request_permissions) { |
| + MicrophoneCameraState new_microphone_camera_state, |
| + const std::string& media_stream_selected_audio_device, |
| + const std::string& media_stream_selected_video_device, |
| + const std::string& media_stream_requested_audio_device, |
| + const std::string& media_stream_requested_video_device) { |
| media_stream_access_origin_ = request_origin; |
| - MicrophoneCameraState prev_microphone_camera_state = microphone_camera_state_; |
| - microphone_camera_state_ = MICROPHONE_CAMERA_NOT_ACCESSED; |
| - PrefService* prefs = |
| - Profile::FromBrowserContext(web_contents()->GetBrowserContext())-> |
| - GetPrefs(); |
| - MediaStreamDevicesController::MediaStreamTypeSettingsMap::const_iterator it = |
| - request_permissions.find(content::MEDIA_DEVICE_AUDIO_CAPTURE); |
| - if (it != request_permissions.end()) { |
| - media_stream_requested_audio_device_ = it->second.requested_device_id; |
| - media_stream_selected_audio_device_ = |
| - media_stream_requested_audio_device_.empty() ? |
| - prefs->GetString(prefs::kDefaultAudioCaptureDevice) : |
| - media_stream_requested_audio_device_; |
| - DCHECK_NE(MediaStreamDevicesController::MEDIA_NONE, it->second.permission); |
| - bool mic_allowed = |
| - it->second.permission == MediaStreamDevicesController::MEDIA_ALLOWED; |
| - content_allowed_[CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC] = mic_allowed; |
| - content_blocked_[CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC] = !mic_allowed; |
| - microphone_camera_state_ |= |
| - MICROPHONE_ACCESSED | (mic_allowed ? 0 : MICROPHONE_BLOCKED); |
| + if (new_microphone_camera_state & MICROPHONE_ACCESSED) { |
| + media_stream_requested_audio_device_ = media_stream_requested_audio_device; |
| + media_stream_selected_audio_device_ = media_stream_selected_audio_device; |
| + bool mic_blocked = (new_microphone_camera_state & MICROPHONE_BLOCKED) != 0; |
|
vabr (Chromium)
2014/10/28 20:48:43
This != 0 might seem unnecessary, but without it,
Bernhard Bauer
2014/10/29 09:35:17
Yeah, direct assignment can be tricky (I remember
vabr (Chromium)
2014/10/29 10:30:21
If that happens, that would be bad. The C4800 warn
Bernhard Bauer
2014/10/29 13:56:59
TBH, the whole thing seems a bit weird. It's suppo
|
| + content_allowed_[CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC] = !mic_blocked; |
| + content_blocked_[CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC] = mic_blocked; |
| } |
| - it = request_permissions.find(content::MEDIA_DEVICE_VIDEO_CAPTURE); |
| - if (it != request_permissions.end()) { |
| - media_stream_requested_video_device_ = it->second.requested_device_id; |
| - media_stream_selected_video_device_ = |
| - media_stream_requested_video_device_.empty() ? |
| - prefs->GetString(prefs::kDefaultVideoCaptureDevice) : |
| - media_stream_requested_video_device_; |
| - DCHECK_NE(MediaStreamDevicesController::MEDIA_NONE, it->second.permission); |
| - bool cam_allowed = |
| - it->second.permission == MediaStreamDevicesController::MEDIA_ALLOWED; |
| - content_allowed_[CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA] = cam_allowed; |
| - content_blocked_[CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA] = !cam_allowed; |
| - microphone_camera_state_ |= |
| - CAMERA_ACCESSED | (cam_allowed ? 0 : CAMERA_BLOCKED); |
| + if (new_microphone_camera_state & CAMERA_ACCESSED) { |
| + media_stream_requested_video_device_ = media_stream_requested_video_device; |
| + media_stream_selected_video_device_ = media_stream_selected_video_device; |
| + bool cam_blocked = (new_microphone_camera_state & CAMERA_BLOCKED) != 0; |
| + content_allowed_[CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA] = !cam_blocked; |
| + content_blocked_[CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA] = cam_blocked; |
| } |
| - if (microphone_camera_state_ != prev_microphone_camera_state) { |
| + if (microphone_camera_state_ != new_microphone_camera_state) { |
| + microphone_camera_state_ = new_microphone_camera_state; |
| content::NotificationService::current()->Notify( |
| chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, |
| content::Source<WebContents>(web_contents()), |