Commit b5bdc990 authored by Jordan Bayles's avatar Jordan Bayles Committed by Commit Bot

[MediaRouter] Add warning for invalid permissions

This patch adds a new check to the media router views UI that, on Mac OS
X 10.15+ (Catalina), checks if the screen capture permission has been
granted, and shows a warning message and fails to cast if so.

Bug: 1087236
Change-Id: I3afdfdb06a011fee3e6fd5f199d375d0ab6eef88
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2298479
Commit-Queue: Jordan Bayles <jophba@chromium.org>
Reviewed-by: default avatarTakumi Fujimoto <takumif@chromium.org>
Cr-Commit-Position: refs/heads/master@{#789194}
parent f6d990a9
...@@ -76,8 +76,13 @@ ...@@ -76,8 +76,13 @@
<message name="IDS_MEDIA_ROUTER_ISSUE_TAB_AUDIO_NOT_SUPPORTED" desc="Title of an issue shown when the user is casting a tab, but only its visual content can be cast and not its audio output."> <message name="IDS_MEDIA_ROUTER_ISSUE_TAB_AUDIO_NOT_SUPPORTED" desc="Title of an issue shown when the user is casting a tab, but only its visual content can be cast and not its audio output.">
Casting tab audio is not supported on this device. Casting tab audio is not supported on this device.
</message> </message>
<if expr="is_macosx">
<message name="IDS_MEDIA_ROUTER_ISSUE_MAC_SCREEN_CAPTURE_PERMISSION_ERROR" desc="Title of an issue shown when the user is casting a window or desktop, and the associated MAC OS X 10.15+ system permission for 'Screen Recording' is not granted.">
Unable to cast screen. Check the Screen Recording permission in System Preferences.
</message>
</if>
<!-- Sink List --> <!-- Sink List -->
<message name="IDS_MEDIA_ROUTER_STATUS_LOOKING_FOR_DEVICES" desc="Status text temporarily shown while searching for Cast devices but none have been found."> <message name="IDS_MEDIA_ROUTER_STATUS_LOOKING_FOR_DEVICES" desc="Status text temporarily shown while searching for Cast devices but none have been found.">
Looking for devices Looking for devices
</message> </message>
......
...@@ -54,6 +54,11 @@ ...@@ -54,6 +54,11 @@
#include "ui/display/display.h" #include "ui/display/display.h"
#include "url/origin.h" #include "url/origin.h"
#if defined(OS_MACOSX)
#include "base/mac/mac_util.h"
#include "ui/base/cocoa/permissions_utils.h"
#endif
namespace media_router { namespace media_router {
namespace { namespace {
...@@ -368,6 +373,15 @@ bool MediaRouterViewsUI::CreateRoute(const MediaSink::Id& sink_id, ...@@ -368,6 +373,15 @@ bool MediaRouterViewsUI::CreateRoute(const MediaSink::Id& sink_id,
return false; return false;
} }
#if defined(OS_MACOSX)
if (base::mac::IsAtLeastOS10_15() &&
cast_mode == MediaCastMode::DESKTOP_MIRROR &&
!ui::IsScreenCaptureAllowed()) {
SendIssueForScreenPermission(sink_id);
return false;
}
#endif
GetIssueManager()->ClearNonBlockingIssues(); GetIssueManager()->ClearNonBlockingIssues();
auto on_document_available = base::BindOnce( auto on_document_available = base::BindOnce(
...@@ -745,6 +759,18 @@ void MediaRouterViewsUI::SendIssueForRouteTimeout( ...@@ -745,6 +759,18 @@ void MediaRouterViewsUI::SendIssueForRouteTimeout(
AddIssue(issue_info); AddIssue(issue_info);
} }
#if defined(OS_MACOSX)
void MediaRouterViewsUI::SendIssueForScreenPermission(
const MediaSink::Id& sink_id) {
std::string issue_title = l10n_util::GetStringUTF8(
IDS_MEDIA_ROUTER_ISSUE_MAC_SCREEN_CAPTURE_PERMISSION_ERROR);
IssueInfo issue_info(issue_title, IssueInfo::Action::DISMISS,
IssueInfo::Severity::WARNING);
issue_info.sink_id = sink_id;
AddIssue(issue_info);
}
#endif
void MediaRouterViewsUI::SendIssueForUnableToCast( void MediaRouterViewsUI::SendIssueForUnableToCast(
MediaCastMode cast_mode, MediaCastMode cast_mode,
const MediaSink::Id& sink_id) { const MediaSink::Id& sink_id) {
......
...@@ -233,8 +233,14 @@ class MediaRouterViewsUI ...@@ -233,8 +233,14 @@ class MediaRouterViewsUI
const MediaSink::Id& sink_id, const MediaSink::Id& sink_id,
const base::string16& presentation_request_source_name); const base::string16& presentation_request_source_name);
// Creates and sends an issue if casting fails due to lack of screen
// permissions.
#if defined(OS_MACOSX)
void SendIssueForScreenPermission(const MediaSink::Id& sink_id);
#endif
// Creates and sends an issue if casting fails for any reason other than // Creates and sends an issue if casting fails for any reason other than
// timeout. // those above.
void SendIssueForUnableToCast(MediaCastMode cast_mode, void SendIssueForUnableToCast(MediaCastMode cast_mode,
const MediaSink::Id& sink_id); const MediaSink::Id& sink_id);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment