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

Side by Side Diff: chrome/browser/media/desktop_capture_access_handler.cc

Issue 2291893002: Let Contraints Controll Mute/Unmute Audio Local Playback For Desktop Sharing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove Debug Code Created 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/media/desktop_capture_access_handler.h" 5 #include "chrome/browser/media/desktop_capture_access_handler.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 const base::string16& application_title, 145 const base::string16& application_title,
146 const base::string16& registered_extension_name) { 146 const base::string16& registered_extension_name) {
147 DCHECK_CURRENTLY_ON(BrowserThread::UI); 147 DCHECK_CURRENTLY_ON(BrowserThread::UI);
148 std::unique_ptr<content::MediaStreamUI> ui; 148 std::unique_ptr<content::MediaStreamUI> ui;
149 149
150 // Add selected desktop source to the list. 150 // Add selected desktop source to the list.
151 devices->push_back(content::MediaStreamDevice( 151 devices->push_back(content::MediaStreamDevice(
152 content::MEDIA_DESKTOP_VIDEO_CAPTURE, media_id.ToString(), "Screen")); 152 content::MEDIA_DESKTOP_VIDEO_CAPTURE, media_id.ToString(), "Screen"));
153 if (capture_audio) { 153 if (capture_audio) {
154 if (media_id.type == content::DesktopMediaID::TYPE_WEB_CONTENTS) { 154 if (media_id.type == content::DesktopMediaID::TYPE_WEB_CONTENTS) {
155 content::WebContentsMediaCaptureId web_id = media_id.web_contents_id;
156 web_id.mute_source = mute_system_audio;
155 devices->push_back( 157 devices->push_back(
156 content::MediaStreamDevice(content::MEDIA_DESKTOP_AUDIO_CAPTURE, 158 content::MediaStreamDevice(content::MEDIA_DESKTOP_AUDIO_CAPTURE,
157 media_id.ToString(), "Tab audio")); 159 web_id.ToString(), "Tab audio"));
158 } else if (mute_system_audio) { 160 } else if (mute_system_audio) {
159 // Use the special loopback device ID for system audio capture. 161 // Use the special loopback device ID for system audio capture.
160 devices->push_back(content::MediaStreamDevice( 162 devices->push_back(content::MediaStreamDevice(
161 content::MEDIA_DESKTOP_AUDIO_CAPTURE, 163 content::MEDIA_DESKTOP_AUDIO_CAPTURE,
162 media::AudioDeviceDescription::kLoopbackWithMuteDeviceId, 164 media::AudioDeviceDescription::kLoopbackWithMuteDeviceId,
163 "System Audio")); 165 "System Audio"));
164 } else { 166 } else {
165 // Use the special loopback device ID for system audio capture. 167 // Use the special loopback device ID for system audio capture.
166 devices->push_back(content::MediaStreamDevice( 168 devices->push_back(content::MediaStreamDevice(
167 content::MEDIA_DESKTOP_AUDIO_CAPTURE, 169 content::MEDIA_DESKTOP_AUDIO_CAPTURE,
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 #endif // !defined(OS_CHROMEOS) 311 #endif // !defined(OS_CHROMEOS)
310 312
311 bool capture_audio = 313 bool capture_audio =
312 (request.audio_type == content::MEDIA_DESKTOP_AUDIO_CAPTURE && 314 (request.audio_type == content::MEDIA_DESKTOP_AUDIO_CAPTURE &&
313 loopback_audio_supported); 315 loopback_audio_supported);
314 316
315 // Unless we're being invoked from a component extension, register to 317 // Unless we're being invoked from a component extension, register to
316 // display the notification for stream capture. 318 // display the notification for stream capture.
317 bool display_notification = !component_extension; 319 bool display_notification = !component_extension;
318 320
319 ui = GetDevicesForDesktopCapture(&devices, screen_id, capture_audio, true, 321 ui = GetDevicesForDesktopCapture(
320 display_notification, application_title, 322 &devices, screen_id, capture_audio, request.mute_source,
321 application_title); 323 display_notification, application_title, application_title);
322 DCHECK(!devices.empty()); 324 DCHECK(!devices.empty());
323 } 325 }
324 326
325 // The only case when devices can be empty is if the user has denied 327 // The only case when devices can be empty is if the user has denied
326 // permission. 328 // permission.
327 result = devices.empty() ? content::MEDIA_DEVICE_PERMISSION_DENIED 329 result = devices.empty() ? content::MEDIA_DEVICE_PERMISSION_DENIED
328 : content::MEDIA_DEVICE_OK; 330 : content::MEDIA_DEVICE_OK;
329 } 331 }
330 332
331 callback.Run(devices, result, std::move(ui)); 333 callback.Run(devices, result, std::move(ui));
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 loopback_audio_supported) || 420 loopback_audio_supported) ||
419 media_id.type == content::DesktopMediaID::TYPE_WEB_CONTENTS; 421 media_id.type == content::DesktopMediaID::TYPE_WEB_CONTENTS;
420 422
421 const bool check_audio_permission = 423 const bool check_audio_permission =
422 !base::CommandLine::ForCurrentProcess()->HasSwitch( 424 !base::CommandLine::ForCurrentProcess()->HasSwitch(
423 extensions::switches::kDisableDesktopCaptureAudio); 425 extensions::switches::kDisableDesktopCaptureAudio);
424 const bool capture_audio = 426 const bool capture_audio =
425 (check_audio_permission ? audio_permitted : true) && audio_requested && 427 (check_audio_permission ? audio_permitted : true) && audio_requested &&
426 audio_supported; 428 audio_supported;
427 429
428 ui = GetDevicesForDesktopCapture(&devices, media_id, capture_audio, false, 430 ui = GetDevicesForDesktopCapture(&devices, media_id, capture_audio,
429 true, 431 request.mute_source, true,
430 GetApplicationTitle(web_contents, extension), 432 GetApplicationTitle(web_contents, extension),
431 base::UTF8ToUTF16(original_extension_name)); 433 base::UTF8ToUTF16(original_extension_name));
432 UpdateExtensionTrusted(request, extension); 434 UpdateExtensionTrusted(request, extension);
433 callback.Run(devices, content::MEDIA_DEVICE_OK, std::move(ui)); 435 callback.Run(devices, content::MEDIA_DEVICE_OK, std::move(ui));
434 } 436 }
435 437
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698