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

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

Issue 1644073002: Desktop Share Audio User Permission (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Compiler Issue Created 4 years, 11 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/desktop_capture_access_handler.cc
diff --git a/chrome/browser/media/desktop_capture_access_handler.cc b/chrome/browser/media/desktop_capture_access_handler.cc
index 5bf01c197b07a928f4368bd0402836af4b36547e..1eced4608ce55066c04e7b3473e0da422c1eb400 100644
--- a/chrome/browser/media/desktop_capture_access_handler.cc
+++ b/chrome/browser/media/desktop_capture_access_handler.cc
@@ -31,6 +31,7 @@
#include "extensions/browser/app_window/app_window_registry.h"
#include "extensions/common/constants.h"
#include "extensions/common/extension.h"
+#include "extensions/common/switches.h"
#include "media/audio/audio_manager_base.h"
#include "net/base/url_util.h"
#include "third_party/webrtc/modules/desktop_capture/desktop_capture_types.h"
@@ -343,11 +344,25 @@ void DesktopCaptureAccessHandler::HandleRequest(
loopback_audio_supported = true;
#endif
- // Audio is only supported for screen capture streams.
+ // This value essentially from the checkbox on picker window, so it
+ // corresponds to user permission.
+ bool audio_permitted = media_id.audio_share;
+
+ // This value essentially from whether getUserMedia requests audio stream.
+ bool audio_requested =
+ request.audio_type == content::MEDIA_DESKTOP_AUDIO_CAPTURE;
+
+ // This value shows for a given capture type, whether the system or our code
+ // can support audio sharing. Currently audio is only supported for screen
+ // capture streams.
+ bool audio_supported =
+ media_id.type == content::DesktopMediaID::TYPE_SCREEN &&
+ loopback_audio_supported;
+
+ bool has_flag = base::CommandLine::ForCurrentProcess()->HasSwitch(
+ extensions::switches::kEnableDesktopCaptureAudio);
bool capture_audio =
- (media_id.type == content::DesktopMediaID::TYPE_SCREEN &&
- request.audio_type == content::MEDIA_DESKTOP_AUDIO_CAPTURE &&
- loopback_audio_supported);
+ (has_flag ? audio_permitted : true) && audio_requested && audio_supported;
ui = GetDevicesForDesktopCapture(&devices, media_id, capture_audio, true,
GetApplicationTitle(web_contents, extension),

Powered by Google App Engine
This is Rietveld 408576698