RemoteMacViews: Add AppShimHostBootstrap::GetAppShimPid
This will be queried in ExtensionAppShimHandler::OnProfileLoaded, where
we will check that the pid's signature.
Bug: 913362
Change-Id: I6fd144b26fad182d040f302f078a343cd2ab6cd9
Reviewed-on: https://chromium-review.googlesource.com/c/1373433
Commit-Queue: ccameron <ccameron@chromium.org>
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#615930}diff --git a/chrome/browser/apps/app_shim/app_shim_host_bootstrap_mac.cc b/chrome/browser/apps/app_shim/app_shim_host_bootstrap_mac.cc
index 5bdaec7a..42425512 100644
--- a/chrome/browser/apps/app_shim/app_shim_host_bootstrap_mac.cc
+++ b/chrome/browser/apps/app_shim/app_shim_host_bootstrap_mac.cc
@@ -4,6 +4,9 @@
#include "chrome/browser/apps/app_shim/app_shim_host_bootstrap_mac.h"
+#include <sys/socket.h>
+#include <sys/un.h>
+
#include <memory>
#include <utility>
@@ -28,6 +31,15 @@
void AppShimHostBootstrap::ServeChannel(
mojo::PlatformChannelEndpoint endpoint) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
+
+ DCHECK(endpoint.platform_handle().is_fd());
+ socklen_t pid_size = sizeof(pid_);
+ if (getsockopt(endpoint.platform_handle().GetFD().get(), SOL_LOCAL,
+ LOCAL_PEERPID, &pid_, &pid_size)) {
+ LOG(ERROR) << "Failed to get peer pid for app shim.";
+ return;
+ }
+
mojo::ScopedMessagePipeHandle message_pipe =
bootstrap_mojo_connection_.Connect(std::move(endpoint));
host_bootstrap_binding_.Bind(
diff --git a/chrome/browser/apps/app_shim/app_shim_host_bootstrap_mac.h b/chrome/browser/apps/app_shim/app_shim_host_bootstrap_mac.h
index 3e07709..b916201 100644
--- a/chrome/browser/apps/app_shim/app_shim_host_bootstrap_mac.h
+++ b/chrome/browser/apps/app_shim/app_shim_host_bootstrap_mac.h
@@ -10,6 +10,7 @@
#include "base/files/file_path.h"
#include "base/macros.h"
+#include "base/process/process_handle.h"
#include "base/threading/thread_checker.h"
#include "chrome/browser/apps/app_shim/app_shim_host_mac.h"
#include "chrome/common/mac/app_shim.mojom.h"
@@ -29,6 +30,7 @@
void OnLaunchAppFailed(apps::AppShimLaunchResult result);
chrome::mojom::AppShimHostRequest GetLaunchAppShimHostRequest();
+ base::ProcessId GetAppShimPid() const { return pid_; }
const std::string& GetAppId() const { return app_id_; }
const base::FilePath& GetProfilePath() const { return profile_path_; }
@@ -59,6 +61,7 @@
// The arguments from the LaunchApp call, and whether or not it has happened
// yet.
bool has_received_launch_app_ = false;
+ base::ProcessId pid_ = 0;
chrome::mojom::AppShimHostRequest app_shim_host_request_;
base::FilePath profile_path_;
std::string app_id_;