WebXR: opt AR & VR into temporary permissions

Additionally, fix a likely copy-paste error with some strings ending
with ".." instead of a single period.

Bug: b:391964646
Change-Id: If53af9fe5bb40e9759ff6e04024975790f3660eb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6341151
Reviewed-by: Balazs Engedy <engedy@chromium.org>
Reviewed-by: Florian Jacky <fjacky@chromium.org>
Commit-Queue: Piotr Bialecki <bialpio@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1435679}
diff --git a/components/content_settings/core/browser/content_settings_utils.cc b/components/content_settings/core/browser/content_settings_utils.cc
index d82e59b..e4fc968 100644
--- a/components/content_settings/core/browser/content_settings_utils.cc
+++ b/components/content_settings/core/browser/content_settings_utils.cc
@@ -245,6 +245,8 @@
       ContentSettingsType::MEDIASTREAM_CAMERA,
       ContentSettingsType::HAND_TRACKING,
       ContentSettingsType::SMART_CARD_DATA,
+      ContentSettingsType::AR,
+      ContentSettingsType::VR,
   }};
   return *types;
 }
@@ -260,6 +262,8 @@
       ContentSettingsType::MEDIASTREAM_MIC,
       ContentSettingsType::MEDIASTREAM_CAMERA,
       ContentSettingsType::HAND_TRACKING,
+      ContentSettingsType::AR,
+      ContentSettingsType::VR,
   }};
   return *types;
 }
diff --git a/components/permissions/contexts/webxr_permission_context.cc b/components/permissions/contexts/webxr_permission_context.cc
index 2db77b6..e46f706 100644
--- a/components/permissions/contexts/webxr_permission_context.cc
+++ b/components/permissions/contexts/webxr_permission_context.cc
@@ -51,9 +51,6 @@
     ContentSetting content_setting,
     bool is_one_time,
     bool is_final_decision) {
-  const bool is_hands =
-      content_settings_type_ == ContentSettingsType::HAND_TRACKING;
-  DCHECK(!is_one_time || is_hands);
   DCHECK(is_final_decision);
 
   // Note that this method calls into base class implementation version of
@@ -69,12 +66,14 @@
   // non-OpenXR VR.
   const bool permission_granted =
       content_setting == ContentSetting::CONTENT_SETTING_ALLOW;
-  const bool is_ar = content_settings_type_ == ContentSettingsType::AR;
   bool is_openxr = false;
 #if BUILDFLAG(ENABLE_OPENXR)
   is_openxr = content_settings_type_ == ContentSettingsType::VR &&
               device::features::IsOpenXrEnabled();
 #endif
+  const bool is_hands =
+      content_settings_type_ == ContentSettingsType::HAND_TRACKING;
+  const bool is_ar = content_settings_type_ == ContentSettingsType::AR;
   const bool additional_permissions_needed =
       permission_granted && (is_ar || is_openxr || is_hands);
   if (!additional_permissions_needed) {
diff --git a/components/permissions/permission_request.cc b/components/permissions/permission_request.cc
index b24f1977..d6c9fa6 100644
--- a/components/permissions/permission_request.cc
+++ b/components/permissions/permission_request.cc
@@ -204,7 +204,13 @@
     ChipTextType type) const {
   static base::NoDestructor<std::map<RequestType, std::vector<int>>> kMessageIds(
       {{RequestType::kArSession,
-        {IDS_AR_PERMISSION_CHIP, -1, -1, -1, -1, -1, -1, -1}},
+        {IDS_AR_PERMISSION_CHIP, -1,
+         IDS_PERMISSIONS_PERMISSION_ALLOWED_CONFIRMATION,
+         IDS_PERMISSIONS_PERMISSION_ALLOWED_ONCE_CONFIRMATION,
+         IDS_PERMISSIONS_PERMISSION_NOT_ALLOWED_CONFIRMATION,
+         IDS_PERMISSIONS_AR_ALLOWED_CONFIRMATION_SCREENREADER_ANNOUNCEMENT,
+         IDS_PERMISSIONS_AR_ALLOWED_ONCE_CONFIRMATION_SCREENREADER_ANNOUNCEMENT,
+         IDS_PERMISSIONS_AR_NOT_ALLOWED_CONFIRMATION_SCREENREADER_ANNOUNCEMENT}},
        {RequestType::kCameraStream,
         {IDS_MEDIA_CAPTURE_VIDEO_ONLY_PERMISSION_CHIP, -1,
          IDS_PERMISSIONS_PERMISSION_ALLOWED_CONFIRMATION,
@@ -285,7 +291,13 @@
          IDS_PERMISSIONS_SAA_ALLOWED_CONFIRMATION_SCREENREADER_ANNOUNCEMENT, -1,
          IDS_PERMISSIONS_SAA_NOT_ALLOWED_CONFIRMATION_SCREENREADER_ANNOUNCEMENT}},
        {RequestType::kVrSession,
-        {IDS_VR_PERMISSION_CHIP, -1, -1, -1, -1, -1, -1, -1}},
+        {IDS_VR_PERMISSION_CHIP, -1,
+         IDS_PERMISSIONS_PERMISSION_ALLOWED_CONFIRMATION,
+         IDS_PERMISSIONS_PERMISSION_ALLOWED_ONCE_CONFIRMATION,
+         IDS_PERMISSIONS_PERMISSION_NOT_ALLOWED_CONFIRMATION,
+         IDS_PERMISSIONS_VR_ALLOWED_CONFIRMATION_SCREENREADER_ANNOUNCEMENT,
+         IDS_PERMISSIONS_VR_ALLOWED_ONCE_CONFIRMATION_SCREENREADER_ANNOUNCEMENT,
+         IDS_PERMISSIONS_VR_NOT_ALLOWED_CONFIRMATION_SCREENREADER_ANNOUNCEMENT}},
        {RequestType::kWebAppInstallation,
         {IDS_WEB_APP_INSTALLATION_PERMISSION_CHIP, -1,
          IDS_PERMISSIONS_PERMISSION_ALLOWED_CONFIRMATION,
diff --git a/components/permissions_strings.grdp b/components/permissions_strings.grdp
index 121da12..1e3b5fe1 100644
--- a/components/permissions_strings.grdp
+++ b/components/permissions_strings.grdp
@@ -311,12 +311,6 @@
     <message name="IDS_SAA_PERMISSION_CHIP" desc="Button text representing a request for using Storage Access API from a website embedded in another website. When clicked, shows a permission prompt bubble with more information.">
       Allow embedded content?
     </message>
-    <message name="IDS_VR_PERMISSION_CHIP" desc="Button text representing a request for using VR from a website. When clicked, shows a permission prompt bubble with more information.">
-      Allow VR?
-    </message>
-    <message name="IDS_AR_PERMISSION_CHIP" desc="Button text representing a request for using AR from a website. When clicked, shows a permission prompt bubble with more information.">
-      Allow AR?
-    </message>
     <message name="IDS_IDLE_DETECTION_PERMISSION_CHIP" desc="Button text representing a request for using using idle detection from a website. When clicked, shows a permission prompt bubble with more information.">
       Know your device use?
     </message>
@@ -333,13 +327,39 @@
       Install web apps?
     </message>
 
+    <message name="IDS_AR_PERMISSION_CHIP" desc="Button text representing a request for using AR from a website. When clicked, shows a permission prompt bubble with more information.">
+      Allow AR?
+    </message>
+    <message name="IDS_PERMISSIONS_AR_ALLOWED_CONFIRMATION_SCREENREADER_ANNOUNCEMENT" is_accessibility_with_no_ui="true" desc="Announcement to screen readers confirming that an AR permission requested has been granted.">
+      AR allowed
+    </message>
+    <message name="IDS_PERMISSIONS_AR_ALLOWED_ONCE_CONFIRMATION_SCREENREADER_ANNOUNCEMENT" is_accessibility_with_no_ui="true" desc="Announcement to screen readers confirming that an AR permission requested has been granted once.">
+      AR allowed this time
+    </message>
+    <message name="IDS_PERMISSIONS_AR_NOT_ALLOWED_CONFIRMATION_SCREENREADER_ANNOUNCEMENT" is_accessibility_with_no_ui="true" desc="Announcement to screen readers confirming that an AR permission requested has been denied.">
+      AR not allowed
+    </message>
+
+    <message name="IDS_VR_PERMISSION_CHIP" desc="Button text representing a request for using VR from a website. When clicked, shows a permission prompt bubble with more information.">
+      Allow VR?
+    </message>
+    <message name="IDS_PERMISSIONS_VR_ALLOWED_CONFIRMATION_SCREENREADER_ANNOUNCEMENT" is_accessibility_with_no_ui="true" desc="Announcement to screen readers confirming that a VR permission requested has been granted.">
+      VR allowed
+    </message>
+    <message name="IDS_PERMISSIONS_VR_ALLOWED_ONCE_CONFIRMATION_SCREENREADER_ANNOUNCEMENT" is_accessibility_with_no_ui="true" desc="Announcement to screen readers confirming that a VR permission requested has been granted once.">
+      VR allowed this time
+    </message>
+    <message name="IDS_PERMISSIONS_VR_NOT_ALLOWED_CONFIRMATION_SCREENREADER_ANNOUNCEMENT" is_accessibility_with_no_ui="true" desc="Announcement to screen readers confirming that a VR permission requested has been denied.">
+      VR not allowed
+    </message>
+
     <message name="IDS_HAND_TRACKING_PERMISSION_CHIP" desc="Button text representing a request for using hand tracking from a website. When clicked, shows a permission prompt bubble with more information.">
       Allow hand tracking?
     </message>
     <message name="IDS_HAND_TRACKING_PERMISSION_BLOCKED_CHIP" desc="Button text representing a blocked or expired request for using hand tracking from a website. When clicked, shows a permission prompt bubble with more information.">
       Hand tracking blocked
     </message>
-    <message name="IDS_PERMISSIONS_HAND_TRACKING_ALLOWED_CONFIRMATION_SCREENREADER_ANNOUNCEMENT" is_accessibility_with_no_ui="true" desc="Announcement to screen readers confirming that a hand tracking permission requested has been granted..">
+    <message name="IDS_PERMISSIONS_HAND_TRACKING_ALLOWED_CONFIRMATION_SCREENREADER_ANNOUNCEMENT" is_accessibility_with_no_ui="true" desc="Announcement to screen readers confirming that a hand tracking permission requested has been granted.">
       Hand tracking allowed
     </message>
     <message name="IDS_PERMISSIONS_HAND_TRACKING_ALLOWED_ONCE_CONFIRMATION_SCREENREADER_ANNOUNCEMENT" is_accessibility_with_no_ui="true" desc="Announcement to screen readers confirming that a hand tracking permission requested has been granted once.">
@@ -384,7 +404,7 @@
       <message name="IDS_PERMISSIONS_NOTIFICATION_NOT_ALLOWED_CONFIRMATION_SCREENREADER_ANNOUNCEMENT" is_accessibility_with_no_ui="true" desc="Announcement to screen readers confirming that a notification permission requested has been denied.">
         Notifications not allowed
     </message>
-      <message name="IDS_PERMISSIONS_GEOLOCATION_ALLOWED_CONFIRMATION_SCREENREADER_ANNOUNCEMENT" is_accessibility_with_no_ui="true" desc="Announcement to screen readers confirming that a location permission requested has been granted..">
+      <message name="IDS_PERMISSIONS_GEOLOCATION_ALLOWED_CONFIRMATION_SCREENREADER_ANNOUNCEMENT" is_accessibility_with_no_ui="true" desc="Announcement to screen readers confirming that a location permission requested has been granted.">
         Location allowed
     </message>
     <message name="IDS_PERMISSIONS_GEOLOCATION_ALLOWED_ONCE_CONFIRMATION_SCREENREADER_ANNOUNCEMENT" is_accessibility_with_no_ui="true" desc="Announcement to screen readers confirming that a location permission requested has been granted once.">
@@ -393,7 +413,7 @@
       <message name="IDS_PERMISSIONS_GEOLOCATION_NOT_ALLOWED_CONFIRMATION_SCREENREADER_ANNOUNCEMENT" is_accessibility_with_no_ui="true" desc="Announcement to screen readers confirming that a location permission requested has been denied.">
         Location not allowed
     </message>
-    <message name="IDS_PERMISSIONS_CAMERA_ALLOWED_CONFIRMATION_SCREENREADER_ANNOUNCEMENT" is_accessibility_with_no_ui="true" desc="Announcement to screen readers confirming that a camera permission requested has been granted..">
+    <message name="IDS_PERMISSIONS_CAMERA_ALLOWED_CONFIRMATION_SCREENREADER_ANNOUNCEMENT" is_accessibility_with_no_ui="true" desc="Announcement to screen readers confirming that a camera permission requested has been granted.">
         Camera allowed
     </message>
     <message name="IDS_PERMISSIONS_CAMERA_ALLOWED_ONCE_CONFIRMATION_SCREENREADER_ANNOUNCEMENT" is_accessibility_with_no_ui="true" desc="Announcement to screen readers confirming that a camera permission requested has been granted once.">