Commit d99d9a8e authored by Lambros Lambrou's avatar Lambros Lambrou Committed by Commit Bot

Trigger fake screen-capture when checking permissions.

The permissions-wizard checks host permissions by running the
(Me2Me or It2Me) host binary with a command-line parameter. This CL
ensures that the binary triggers a fake capturer in this situation.
This causes the Security & Privacy screen to include the app in the
list, so the user can check its box.

Bug: 1027317
Change-Id: Icb38737170c5dcaa544499c9708d907845b95845
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1930546
Commit-Queue: Lambros Lambrou <lambroslambrou@chromium.org>
Commit-Queue: Yuwei Huang <yuweih@chromium.org>
Auto-Submit: Lambros Lambrou <lambroslambrou@chromium.org>
Reviewed-by: default avatarYuwei Huang <yuweih@chromium.org>
Cr-Commit-Position: refs/heads/master@{#718303}
parent 892ef7a4
...@@ -37,7 +37,9 @@ ...@@ -37,7 +37,9 @@
#endif // defined(OS_LINUX) #endif // defined(OS_LINUX)
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
#include "base/mac/mac_util.h"
#include "base/mac/scoped_nsautorelease_pool.h" #include "base/mac/scoped_nsautorelease_pool.h"
#include "remoting/host/desktop_capturer_checker.h"
#include "remoting/host/mac/permission_utils.h" #include "remoting/host/mac/permission_utils.h"
#endif // defined(OS_MACOSX) #endif // defined(OS_MACOSX)
...@@ -212,9 +214,16 @@ int It2MeNativeMessagingHostMain(int argc, char** argv) { ...@@ -212,9 +214,16 @@ int It2MeNativeMessagingHostMain(int argc, char** argv) {
return mac::CanInjectInput() ? EXIT_SUCCESS : EXIT_FAILURE; return mac::CanInjectInput() ? EXIT_SUCCESS : EXIT_FAILURE;
} }
if (cmd_line->HasSwitch(kCheckScreenRecordingPermissionSwitchName)) { if (cmd_line->HasSwitch(kCheckScreenRecordingPermissionSwitchName)) {
// Trigger screen-capture, even if CanRecordScreen() returns true. It uses a
// heuristic that might not be 100% reliable, but it is critically
// important to add the host bundle to the list of apps under
// Security & Privacy -> Screen Recording.
if (base::mac::IsAtLeastOS10_15()) {
DesktopCapturerChecker().TriggerSingleCapture();
}
return mac::CanRecordScreen() ? EXIT_SUCCESS : EXIT_FAILURE; return mac::CanRecordScreen() ? EXIT_SUCCESS : EXIT_FAILURE;
} }
#endif #endif // defined(OS_MACOSX)
// NetworkChangeNotifier must be initialized after SingleThreadTaskExecutor. // NetworkChangeNotifier must be initialized after SingleThreadTaskExecutor.
std::unique_ptr<net::NetworkChangeNotifier> network_change_notifier( std::unique_ptr<net::NetworkChangeNotifier> network_change_notifier(
......
...@@ -507,6 +507,14 @@ bool HostProcess::InitWithCommandLine(const base::CommandLine* cmd_line) { ...@@ -507,6 +507,14 @@ bool HostProcess::InitWithCommandLine(const base::CommandLine* cmd_line) {
return false; return false;
} }
if (cmd_line->HasSwitch(kCheckScreenRecordingPermissionSwitchName)) { if (cmd_line->HasSwitch(kCheckScreenRecordingPermissionSwitchName)) {
// Trigger screen-capture, even if CanRecordScreen() returns true. It uses a
// heuristic that might not be 100% reliable, but it is critically
// important to add the host bundle to the list of apps under
// Security & Privacy -> Screen Recording.
if (base::mac::IsAtLeastOS10_15()) {
capture_checker_ = std::make_unique<DesktopCapturerChecker>();
capture_checker_->TriggerSingleCapture();
}
checking_permission_state_ = true; checking_permission_state_ = true;
permission_granted_ = mac::CanRecordScreen(); permission_granted_ = mac::CanRecordScreen();
return false; return false;
......
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