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

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

Issue 2400803003: [Media Router] Remove desktop capture prompts. (Closed)
Patch Set: Revert BUILD.gn Created 4 years, 2 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
« no previous file with comments | « chrome/browser/media/webrtc/desktop_capture_access_handler.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/media/webrtc/desktop_capture_access_handler.cc
diff --git a/chrome/browser/media/webrtc/desktop_capture_access_handler.cc b/chrome/browser/media/webrtc/desktop_capture_access_handler.cc
index 557e24d610a8a481e6e64d3f6433caea4f2a3331..5c3d2e0ac963c5c76a6811aeadddbb5d5bde49f7 100644
--- a/chrome/browser/media/webrtc/desktop_capture_access_handler.cc
+++ b/chrome/browser/media/webrtc/desktop_capture_access_handler.cc
@@ -62,6 +62,15 @@ base::string16 GetApplicationTitle(content::WebContents* web_contents,
return base::UTF8ToUTF16(title);
}
+// Returns whether an on-screen notification should appear after desktop capture
+// is approved for |extension|. Component extensions do not display a
+// notification.
+bool ShouldDisplayNotification(const extensions::Extension* extension) {
+ return !(extension &&
+ (extension->location() == extensions::Manifest::COMPONENT ||
+ extension->location() == extensions::Manifest::EXTERNAL_COMPONENT));
+}
+
base::string16 GetStopSharingUIString(
const base::string16& application_title,
const base::string16& registered_extension_name,
@@ -147,6 +156,13 @@ std::unique_ptr<content::MediaStreamUI> GetDevicesForDesktopCapture(
DCHECK_CURRENTLY_ON(BrowserThread::UI);
std::unique_ptr<content::MediaStreamUI> ui;
+ DVLOG(2) << __FUNCTION__ << ": media_id " << media_id.ToString()
+ << ", capture_audio " << capture_audio << ", mute_system_audio "
+ << mute_system_audio << ", display_notification "
+ << display_notification << ", application_title "
+ << application_title << ", extension_name "
+ << registered_extension_name;
+
// Add selected desktop source to the list.
devices->push_back(content::MediaStreamDevice(
content::MEDIA_DESKTOP_VIDEO_CAPTURE, media_id.ToString(), "Screen"));
@@ -230,10 +246,6 @@ void DesktopCaptureAccessHandler::ProcessScreenCaptureAccessRequest(
loopback_audio_supported = true;
#endif
- bool component_extension = false;
- component_extension =
- extension && extension->location() == extensions::Manifest::COMPONENT;
-
bool screen_capture_enabled =
base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableUserMediaScreenCapturing) ||
@@ -274,12 +286,9 @@ void DesktopCaptureAccessHandler::ProcessScreenCaptureAccessRequest(
#endif
web_contents = NULL;
- bool whitelisted_extension =
- IsExtensionWhitelistedForScreenCapture(extension);
-
- // For whitelisted or component extensions, bypass message box.
- bool user_approved = false;
- if (!whitelisted_extension && !component_extension) {
+ // Some extensions do not require user approval.
miu 2016/10/09 03:00:09 Consider adding: "because they already provide the
+ bool is_approved = IsDefaultApproved(extension);
+ if (!is_approved) {
base::string16 application_name =
base::UTF8ToUTF16(request.security_origin.spec());
if (extension)
@@ -294,10 +303,10 @@ void DesktopCaptureAccessHandler::ProcessScreenCaptureAccessRequest(
l10n_util::GetStringFUTF16(
IDS_MEDIA_SCREEN_CAPTURE_CONFIRMATION_TITLE, application_name),
confirmation_text);
- user_approved = (result == chrome::MESSAGE_BOX_RESULT_YES);
+ is_approved = (result == chrome::MESSAGE_BOX_RESULT_YES);
}
- if (user_approved || component_extension || whitelisted_extension) {
+ if (is_approved) {
content::DesktopMediaID screen_id;
#if defined(OS_CHROMEOS)
screen_id = content::DesktopMediaID::RegisterAuraWindow(
@@ -312,9 +321,8 @@ void DesktopCaptureAccessHandler::ProcessScreenCaptureAccessRequest(
(request.audio_type == content::MEDIA_DESKTOP_AUDIO_CAPTURE &&
loopback_audio_supported);
- // Unless we're being invoked from a component extension, register to
- // display the notification for stream capture.
- bool display_notification = !component_extension;
+ // Determine if the extension is required to display a notification.
+ const bool display_notification = ShouldDisplayNotification(extension);
ui = GetDevicesForDesktopCapture(&devices, screen_id, capture_audio, true,
display_notification, application_title,
@@ -331,6 +339,14 @@ void DesktopCaptureAccessHandler::ProcessScreenCaptureAccessRequest(
callback.Run(devices, result, std::move(ui));
}
+bool DesktopCaptureAccessHandler::IsDefaultApproved(
Sergey Ulanov 2016/10/10 17:56:16 does this need to be a class method instead of jus
+ const extensions::Extension* extension) {
+ return extension &&
+ (extension->location() == extensions::Manifest::COMPONENT ||
+ extension->location() == extensions::Manifest::EXTERNAL_COMPONENT ||
+ IsExtensionWhitelistedForScreenCapture(extension));
+}
+
bool DesktopCaptureAccessHandler::SupportsStreamType(
const content::MediaStreamType type,
const extensions::Extension* extension) {
@@ -425,11 +441,13 @@ void DesktopCaptureAccessHandler::HandleRequest(
(check_audio_permission ? audio_permitted : true) && audio_requested &&
audio_supported;
+ // Determine if the extension is required to display a notification.
+ const bool display_notification = ShouldDisplayNotification(extension);
+
ui = GetDevicesForDesktopCapture(&devices, media_id, capture_audio, false,
- true,
+ display_notification,
GetApplicationTitle(web_contents, extension),
base::UTF8ToUTF16(original_extension_name));
UpdateExtensionTrusted(request, extension);
callback.Run(devices, content::MEDIA_DEVICE_OK, std::move(ui));
}
-
« no previous file with comments | « chrome/browser/media/webrtc/desktop_capture_access_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698