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

Add command-line permission-checking options to remote_assistance_host

The remoting_me2me_host binary supports 2 command-line options, for
checking Accessibility and Screen Recording permissions on MacOS.
This CL adds the same options to the IT2Me native-messaging host.

Bug: 1013446
Change-Id: I4727e5f58f70580f8f31c551968238a4d49457f0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1914834Reviewed-by: default avatarGary Kacmarcik <garykac@chromium.org>
Commit-Queue: Lambros Lambrou <lambroslambrou@chromium.org>
Cr-Commit-Position: refs/heads/master@{#715162}
parent 95780f73
......@@ -233,6 +233,7 @@ if (!is_chromeos && enable_remoting_host) {
deps += [
":remote_assistance_host_dialog_icon",
"//remoting/host:remoting_infoplist_strings",
"//remoting/host/mac:permission_checking",
"//remoting/resources:copy_locales",
]
if (icu_use_data_file) {
......
......@@ -26,6 +26,7 @@
#include "remoting/host/native_messaging/pipe_messaging_channel.h"
#include "remoting/host/policy_watcher.h"
#include "remoting/host/resources.h"
#include "remoting/host/switches.h"
#include "remoting/host/usage_stats_consent.h"
#if defined(OS_LINUX)
......@@ -37,6 +38,7 @@
#if defined(OS_MACOSX)
#include "base/mac/scoped_nsautorelease_pool.h"
#include "remoting/host/mac/permission_utils.h"
#endif // defined(OS_MACOSX)
#if defined(OS_WIN)
......@@ -204,6 +206,16 @@ int It2MeNativeMessagingHostMain(int argc, char** argv) {
base::SingleThreadTaskExecutor main_task_executor(base::MessagePumpType::UI);
base::RunLoop run_loop;
#if defined(OS_MACOSX)
auto* cmd_line = base::CommandLine::ForCurrentProcess();
if (cmd_line->HasSwitch(kCheckAccessibilityPermissionSwitchName)) {
return mac::CanInjectInput() ? EXIT_SUCCESS : EXIT_FAILURE;
}
if (cmd_line->HasSwitch(kCheckScreenRecordingPermissionSwitchName)) {
return mac::CanRecordScreen() ? EXIT_SUCCESS : EXIT_FAILURE;
}
#endif
// NetworkChangeNotifier must be initialized after SingleThreadTaskExecutor.
std::unique_ptr<net::NetworkChangeNotifier> network_change_notifier(
net::NetworkChangeNotifier::CreateIfNeeded());
......
......@@ -189,18 +189,6 @@ const char kWindowIdSwitchName[] = "window-id";
// Command line switch used to send a custom offline reason and exit.
const char kReportOfflineReasonSwitchName[] = "report-offline-reason";
#if defined(OS_MACOSX)
// Command line switch to check for Accessibility permission.
const char kCheckAccessibilityPermissionSwitchName[] =
"check-accessibility-permission";
// Command line switch to check for Screen Recording permission.
const char kCheckScreenRecordingPermissionSwitchName[] =
"check-screen-recording-permission";
#endif // defined(OS_MACOSX)
// Maximum time to wait for clean shutdown to occur, before forcing termination
// of the process.
const int kShutdownTimeoutSeconds = 15;
......
......@@ -43,6 +43,10 @@ const char kUpgradeTokenSwitchName[] = "upgrade-token";
#if defined(OS_MACOSX)
const char kCheckPermissionSwitchName[] = "check-permission";
const char kCheckAccessibilityPermissionSwitchName[] =
"check-accessibility-permission";
const char kCheckScreenRecordingPermissionSwitchName[] =
"check-screen-recording-permission";
#endif // defined OS_MACOSX
} // namespace remoting
......@@ -68,6 +68,12 @@ extern const char kUpgradeTokenSwitchName[];
// NativeMessagingHost switch to check for required OS permissions and request
// them if necessary.
extern const char kCheckPermissionSwitchName[];
// Command line switch to check for Accessibility permission.
extern const char kCheckAccessibilityPermissionSwitchName[];
// Command line switch to check for Screen Recording permission.
extern const char kCheckScreenRecordingPermissionSwitchName[];
#endif // defined OS_MACOSX
} // namespace remoting
......
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