Commit 19e52db3 authored by Joe Downing's avatar Joe Downing Committed by Commit Bot

Revert "Revert "[MacOs Host] Provide user with a prompt to enable input injection on Mojave""

This reverts commit 7ee7bac4.

Change-Id: I54247dd56111feee9608e1b50387cb3501a659a4
Reviewed-on: https://chromium-review.googlesource.com/c/1315468Reviewed-by: default avatarGary Kacmarcik <garykac@chromium.org>
Commit-Queue: Joe Downing <joedow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#604947}
parent 1dfcbc57
......@@ -73,6 +73,11 @@ target("mac_app_bundle", "remoting_me2me_host") {
# defines = [ "REMOTING_ENABLE_BREAKPAD" ]
# }
sources = [
"permission_utils.h",
"permission_utils.mm",
]
deps = [
"//remoting/base:breakpad",
"//remoting/host:main",
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef REMOTING_HOST_MAC_PERMISSION_UTILS_H_
#define REMOTING_HOST_MAC_PERMISSION_UTILS_H_
namespace remoting {
namespace mac {
// Prompts the user to add the current application to the set of trusted
// Accessibility applications. This is only required for input injection on
// 10.14 and later OSes.
void PromptUserToChangeTrustStateIfNeeded();
} // namespace mac
} // namespace remoting
#endif // REMOTING_HOST_MAC_PERMISSION_UTILS_H_
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "remoting/host/mac/permission_utils.h"
#import <Cocoa/Cocoa.h>
#include "base/logging.h"
namespace remoting {
namespace mac {
void PromptUserToChangeTrustStateIfNeeded() {
// This method will only display a permission prompt if the application is
// not trusted.
NSDictionary* options = @{(NSString*)kAXTrustedCheckOptionPrompt : @YES };
if (!AXIsProcessTrustedWithOptions((CFDictionaryRef)options)) {
LOG(WARNING) << "AXIsProcessTrustedWithOptions: App is not trusted";
}
}
} // namespace mac
} // namespace remoting
......@@ -112,7 +112,9 @@
#endif // defined(OS_POSIX)
#if defined(OS_MACOSX)
#include "base/mac/mac_util.h"
#include "base/mac/scoped_cftyperef.h"
#include "remoting/host/mac/permission_utils.h"
#endif // defined(OS_MACOSX)
#if defined(OS_LINUX)
......@@ -1569,6 +1571,19 @@ void HostProcess::StartHost() {
HostEventLogger::Create(host_->status_monitor(), kApplicationName);
#endif // !defined(REMOTING_MULTI_PROCESS)
#if defined(OS_MACOSX)
// Ensure we are not running as root (i.e. at the login screen).
DCHECK_NE(getuid(), 0U);
// MacOs 10.14+ requires an addition, runtime permission for injecting input
// using CGEventPost (we use this in our input injector for Mac). This method
// will request that the user enable this permission for us if they are on an
// affected platform and the permission has not already been approved.
if (base::mac::IsAtLeastOS10_14()) {
mac::PromptUserToChangeTrustStateIfNeeded();
}
#endif
host_->Start(host_owner_email_);
CreateAuthenticatorFactory();
......
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