declare local state pref kRemoteAdminWasPresent

Boolean local state pref which will be used to display notification to
the local user when a remote admin has remotely accessed the host device
when no user was present at the device.

Bug: b/291567490
Change-Id: Ifba412c608532ef90386d3e37dd791accf127af0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4670518
Reviewed-by: Joe Downing <[email protected]>
Commit-Queue: Ashutosh Singhal <[email protected]>
Reviewed-by: Ashutosh Singhal <[email protected]>
Reviewed-by: Tommy Nyquist <[email protected]>
Reviewed-by: Jeroen Dhollander <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1175348}
diff --git a/chrome/browser/ash/policy/remote_commands/crd_admin_session_controller.cc b/chrome/browser/ash/policy/remote_commands/crd_admin_session_controller.cc
index e60a2a0..a58496f 100644
--- a/chrome/browser/ash/policy/remote_commands/crd_admin_session_controller.cc
+++ b/chrome/browser/ash/policy/remote_commands/crd_admin_session_controller.cc
@@ -15,6 +15,8 @@
 #include "chrome/browser/ash/policy/remote_commands/crd_logging.h"
 #include "chrome/browser/ash/policy/remote_commands/crd_remote_command_utils.h"
 #include "chrome/browser/ash/policy/remote_commands/device_command_start_crd_session_job.h"
+#include "chrome/common/pref_names.h"
+#include "components/prefs/pref_registry_simple.h"
 #include "mojo/public/cpp/bindings/pending_receiver.h"
 #include "mojo/public/cpp/bindings/receiver.h"
 #include "remoting/host/chromeos/remote_support_host_ash.h"
@@ -325,4 +327,10 @@
   active_session_->Start(parameters);
 }
 
+// static
+void CrdAdminSessionController::RegisterLocalStatePrefs(
+    PrefRegistrySimple* registry) {
+  registry->RegisterBooleanPref(prefs::kRemoteAdminWasPresent, false);
+}
+
 }  // namespace policy
diff --git a/chrome/browser/ash/policy/remote_commands/crd_admin_session_controller.h b/chrome/browser/ash/policy/remote_commands/crd_admin_session_controller.h
index 9c2b27d..42ad83e 100644
--- a/chrome/browser/ash/policy/remote_commands/crd_admin_session_controller.h
+++ b/chrome/browser/ash/policy/remote_commands/crd_admin_session_controller.h
@@ -9,6 +9,7 @@
 
 #include "base/functional/callback_forward.h"
 #include "chrome/browser/ash/policy/remote_commands/device_command_start_crd_session_job.h"
+#include "components/prefs/pref_registry_simple.h"
 #include "remoting/host/chromeos/chromeos_enterprise_params.h"
 #include "remoting/host/chromeos/remote_support_host_ash.h"
 #include "remoting/host/chromeos/session_id.h"
@@ -60,6 +61,8 @@
       delete;
   ~CrdAdminSessionController() override;
 
+  static void RegisterLocalStatePrefs(PrefRegistrySimple* registry);
+
   // DeviceCommandStartCrdSessionJob::Delegate implementation:
   bool HasActiveSession() const override;
   void TerminateSession(base::OnceClosure callback) override;
diff --git a/chrome/browser/prefs/browser_prefs.cc b/chrome/browser/prefs/browser_prefs.cc
index 3d643ec..9dd95e7 100644
--- a/chrome/browser/prefs/browser_prefs.cc
+++ b/chrome/browser/prefs/browser_prefs.cc
@@ -206,6 +206,7 @@
 #include "chrome/browser/ash/net/system_proxy_manager.h"
 #include "chrome/browser/ash/platform_keys/key_permissions/key_permissions_manager_impl.h"
 #include "chrome/browser/ash/policy/networking/euicc_status_uploader.h"
+#include "chrome/browser/ash/policy/remote_commands/crd_admin_session_controller.h"
 #include "chrome/browser/ash/settings/hardware_data_usage_controller.h"
 #include "chrome/browser/ash/settings/stats_reporting_controller.h"
 #include "chrome/browser/component_updater/metadata_table_chromeos.h"
@@ -1549,6 +1550,7 @@
   // TODO(b/265923216): Replace with EnrollmentStateFetcher::RegisterPrefs.
   policy::AutoEnrollmentClientImpl::RegisterPrefs(registry);
   policy::BrowserPolicyConnectorAsh::RegisterPrefs(registry);
+  policy::CrdAdminSessionController::RegisterLocalStatePrefs(registry);
   policy::DeviceCloudPolicyManagerAsh::RegisterPrefs(registry);
   policy::DeviceStatusCollector::RegisterPrefs(registry);
   policy::DeviceWallpaperImageExternalDataHandler::RegisterPrefs(registry);
diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h
index dfec2b0..d91b7920 100644
--- a/chrome/common/pref_names.h
+++ b/chrome/common/pref_names.h
@@ -1242,6 +1242,11 @@
 // "ChromeOS.Settings.NumUniqueSettingsChanged.DeviceLifetime.{Time}".
 const char kHasEverRevokedMetricsConsent[] =
     "settings.has_ever_revoked_metrics_consent";
+
+// A boolean to store that an admin user accessed the host device remotely when
+// no user was present at the device. This boolean enables the device to display
+// a notification to the local user when the session was terminated.
+inline constexpr char kRemoteAdminWasPresent[] = "remote_admin_was_present";
 #endif  // BUILDFLAG(IS_CHROMEOS_ASH)
 
 #if BUILDFLAG(IS_CHROMEOS)