Commit 6c9076bc authored by Guido Urdaneta's avatar Guido Urdaneta Committed by Commit Bot

Update screen sharing system permisison heuristic for macOS Catalina.

Now we consider all windows instead of the visible ones.
Restricting to visible ones caused problems when Chrome was maximized
and some windows required for the heuristic to work were not visible.
Also, this patch removes the check for status windows, since it is
common to have one whose title can be read even with permissions
disabled.

Bug: 1023028
Change-Id: I877bfe518c93961ee3e8e5cc4e768a1ca990eb80
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1917159
Commit-Queue: Guido Urdaneta <guidou@chromium.org>
Reviewed-by: default avatarMarina Ciocea <marinaciocea@chromium.org>
Cr-Commit-Position: refs/heads/master@{#715274}
parent aa606971
...@@ -166,8 +166,8 @@ void RequestSystemMediaCapturePermission(NSString* media_type, ...@@ -166,8 +166,8 @@ void RequestSystemMediaCapturePermission(NSString* media_type,
} }
// Heuristic to check screen capture permission on macOS 10.15. // Heuristic to check screen capture permission on macOS 10.15.
// Screen Capture is considered allowed if the name of at least one normal, // Screen Capture is considered allowed if the name of at least one normal
// dock or status window running on another process is visible. // or dock window running on another process is visible.
// See https://crbug.com/993692. // See https://crbug.com/993692.
bool IsScreenCaptureAllowed() { bool IsScreenCaptureAllowed() {
if (@available(macOS 10.15, *)) { if (@available(macOS 10.15, *)) {
...@@ -176,8 +176,8 @@ bool IsScreenCaptureAllowed() { ...@@ -176,8 +176,8 @@ bool IsScreenCaptureAllowed() {
return true; return true;
} }
base::ScopedCFTypeRef<CFArrayRef> window_list(CGWindowListCopyWindowInfo( base::ScopedCFTypeRef<CFArrayRef> window_list(
kCGWindowListOptionOnScreenOnly, kCGNullWindowID)); CGWindowListCopyWindowInfo(kCGWindowListOptionAll, kCGNullWindowID));
int current_pid = [[NSProcessInfo processInfo] processIdentifier]; int current_pid = [[NSProcessInfo processInfo] processIdentifier];
for (NSDictionary* window in base::mac::CFToNSCast(window_list.get())) { for (NSDictionary* window in base::mac::CFToNSCast(window_list.get())) {
NSNumber* window_pid = NSNumber* window_pid =
...@@ -197,8 +197,7 @@ bool IsScreenCaptureAllowed() { ...@@ -197,8 +197,7 @@ bool IsScreenCaptureAllowed() {
NSInteger layer_integer = [layer integerValue]; NSInteger layer_integer = [layer integerValue];
if (layer_integer == CGWindowLevelForKey(kCGNormalWindowLevelKey) || if (layer_integer == CGWindowLevelForKey(kCGNormalWindowLevelKey) ||
layer_integer == CGWindowLevelForKey(kCGDockWindowLevelKey) || layer_integer == CGWindowLevelForKey(kCGDockWindowLevelKey)) {
layer_integer == CGWindowLevelForKey(kCGStatusWindowLevelKey)) {
return true; return true;
} }
} }
......
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