From 7dae2da57d23f6afa4e88e5f53068b8b15d79a50 Mon Sep 17 00:00:00 2001
From: "W. James MacLean" <wjmaclean@chromium.org>
Date: Mon, 13 Jun 2022 22:01:54 +0000
Subject: [PATCH] Add SiteInstance isolated-sandbox status to
 process-internals.

When a SiteInstance is used for processr-isolating a sandboxed iframe,
reflect that status in chrome://process-internals.

Bug: 510122
Change-Id: Icbf5eb9aa66a29d378a48a57f7ebc1dcec387643
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3704316
Reviewed-by: Nasko Oskov <nasko@chromium.org>
Reviewed-by: Alex Moshchuk <alexmos@chromium.org>
Commit-Queue: James Maclean <wjmaclean@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1013677}
---
 content/browser/process_internals/process_internals.mojom      | 3 +++
 .../process_internals/process_internals_handler_impl.cc        | 2 ++
 content/browser/resources/process/process_internals.ts         | 3 +++
 3 files changed, 8 insertions(+)

diff --git a/content/browser/process_internals/process_internals.mojom b/content/browser/process_internals/process_internals.mojom
index 3fce62e8bf772..26040b038a265 100644
--- a/content/browser/process_internals/process_internals.mojom
+++ b/content/browser/process_internals/process_internals.mojom
@@ -24,6 +24,9 @@ struct SiteInstanceInfo {
   // false otherwise.
   bool requires_origin_keyed_process;
 
+  // Specifies if the SiteInstance is for sandboxed iframe isolation.
+  bool is_sandboxed;
+
   // Specifies whether this SiteInstance is for a <webview> guest.
   bool is_guest;
 
diff --git a/content/browser/process_internals/process_internals_handler_impl.cc b/content/browser/process_internals/process_internals_handler_impl.cc
index e24e68e02a713..0bb4c3f2e8c73 100644
--- a/content/browser/process_internals/process_internals_handler_impl.cc
+++ b/content/browser/process_internals/process_internals_handler_impl.cc
@@ -57,6 +57,8 @@ using IsolatedOriginSource = ChildProcessSecurityPolicy::IsolatedOriginSource;
           ? absl::make_optional(site_instance->GetSiteInfo().site_url())
           : absl::nullopt;
   frame_info->site_instance->is_guest = site_instance->IsGuest();
+  frame_info->site_instance->is_sandboxed =
+      site_instance->GetSiteInfo().is_sandboxed();
 
   // If the SiteInstance has a non-default StoragePartition, include a basic
   // string representation of it.  Skip cases where the StoragePartition is
diff --git a/content/browser/resources/process/process_internals.ts b/content/browser/resources/process/process_internals.ts
index c97d265940c60..645dd93f0b6f5 100644
--- a/content/browser/resources/process/process_internals.ts
+++ b/content/browser/resources/process/process_internals.ts
@@ -113,6 +113,9 @@ function frameToTreeItem(frame: FrameInfo):
   if (frame.siteInstance.requiresOriginKeyedProcess) {
     itemLabel += ', origin-keyed';
   }
+  if (frame.siteInstance.isSandboxed) {
+    itemLabel += ', iframe-sandbox';
+  }
   if (frame.siteInstance.isGuest) {
     itemLabel += ', guest';
   }