[Page Info - Cookies content view] Update the cookies content title and
description if user is 3pcd enabled.

Screenshot:
All cookies not blocked:
https://screenshot.googleplex.com/A3Gk577UssmhCGJ
All cookies are blocked: https://screenshot.googleplex.com/7TXNSzHRi48nxAC


Bug: b/300918726
Change-Id: If42f77c6e181b04e7631349d5ff2b4ef89c9838d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4892207
Commit-Queue: Christian Dullweber <[email protected]>
Reviewed-by: Fiona Macintosh <[email protected]>
Auto-Submit: Alvin Lam <[email protected]>
Reviewed-by: Christian Dullweber <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1202471}
diff --git a/components/page_info/page_info.cc b/components/page_info/page_info.cc
index 33849075..88004c7 100644
--- a/components/page_info/page_info.cc
+++ b/components/page_info/page_info.cc
@@ -425,8 +425,9 @@
 }
 
 void PageInfo::RecordPageInfoAction(PageInfoAction action) {
-  if (action != PAGE_INFO_OPENED)
+  if (action != PAGE_INFO_OPENED) {
     did_perform_action_ = true;
+  }
 
 #if !BUILDFLAG(IS_ANDROID)
   delegate_->OnPageInfoActionOccurred(action);
@@ -442,8 +443,9 @@
   }
 
   auto* settings = GetPageSpecificContentSettings();
-  if (!settings)
+  if (!settings) {
     return;
+  }
 
   bool has_topic = settings->HasAccessedTopics();
   bool has_fledge = settings->HasJoinedUserToInterestGroup();
@@ -738,14 +740,16 @@
 }
 
 void PageInfo::OnUIClosing(bool* reload_prompt) {
-  if (reload_prompt)
+  if (reload_prompt) {
     *reload_prompt = false;
+  }
 #if BUILDFLAG(IS_ANDROID)
   NOTREACHED();
 #else
   if (show_info_bar_ && web_contents_ && !web_contents_->IsBeingDestroyed()) {
-    if (delegate_->CreateInfoBarDelegate() && reload_prompt)
+    if (delegate_->CreateInfoBarDelegate() && reload_prompt) {
       *reload_prompt = true;
+    }
   }
   delegate_->OnUIClosing();
 #endif
@@ -785,10 +789,11 @@
 #else
   auto fps_owner = delegate_->GetFpsOwner(site_url_);
   RecordPageInfoAction(PAGE_INFO_ALL_SITES_WITH_FPS_FILTER_OPENED);
-  if (fps_owner)
+  if (fps_owner) {
     delegate_->ShowAllSitesSettingsFilteredByFpsOwner(*fps_owner);
-  else
+  } else {
     delegate_->ShowAllSitesSettingsFilteredByFpsOwner(std::u16string());
+  }
 
 #endif
 }
@@ -797,8 +802,9 @@
 #if BUILDFLAG(IS_ANDROID)
   NOTREACHED();
 #else
-  if (!web_contents_ || web_contents_->IsBeingDestroyed())
+  if (!web_contents_ || web_contents_->IsBeingDestroyed()) {
     return;
+  }
 
   RecordPageInfoAction(PAGE_INFO_COOKIES_DIALOG_OPENED);
   delegate_->OpenCookiesDialog();
@@ -809,8 +815,9 @@
 #if BUILDFLAG(IS_ANDROID)
   NOTREACHED();
 #else
-  if (!web_contents_ || web_contents_->IsBeingDestroyed())
+  if (!web_contents_ || web_contents_->IsBeingDestroyed()) {
     return;
+  }
 
   gfx::NativeWindow top_window = web_contents_->GetTopLevelNativeWindow();
   if (certificate && top_window) {
@@ -1383,8 +1390,9 @@
   for (const ChooserUIInfo& ui_info : kChooserUIInfo) {
     permissions::ObjectPermissionContextBase* context =
         delegate_->GetChooserContext(ui_info.content_settings_type);
-    if (!context)
+    if (!context) {
       continue;
+    }
     auto chosen_objects = context->GetGrantedObjects(origin);
     for (std::unique_ptr<permissions::ObjectPermissionContextBase::Object>&
              object : chosen_objects) {
@@ -1443,8 +1451,9 @@
 void PageInfo::PresentSiteDataInternal(base::OnceClosure done) {
   // Since this is called asynchronously, the associated `WebContents` object
   // might no longer be available.
-  if (!web_contents_ || web_contents_->IsBeingDestroyed())
+  if (!web_contents_ || web_contents_->IsBeingDestroyed()) {
     return;
+  }
 
   // Presenting site data is only needed if `PageInfoUI` is available.
   if (!ui_) {
@@ -1535,8 +1544,9 @@
 void PageInfo::PresentAdPersonalizationData() {
   PageInfoUI::AdPersonalizationInfo info;
   auto* settings = GetPageSpecificContentSettings();
-  if (!settings)
+  if (!settings) {
     return;
+  }
 
   info.has_joined_user_to_interest_group =
       settings->HasJoinedUserToInterestGroup();
@@ -1570,8 +1580,9 @@
 
 std::vector<ContentSettingsType> PageInfo::GetAllPermissionsForTesting() {
   std::vector<ContentSettingsType> permission_list;
-  for (const ContentSettingsType type : kPermissionType)
+  for (const ContentSettingsType type : kPermissionType) {
     permission_list.push_back(type);
+  }
 
   return permission_list;
 }
@@ -1659,32 +1670,36 @@
 bool PageInfo::HasContentSettingChangedViaPageInfo(
     ContentSettingsType type) const {
   auto* settings = GetPageSpecificContentSettings();
-  if (!settings)
+  if (!settings) {
     return false;
+  }
 
   return settings->HasContentSettingChangedViaPageInfo(type);
 }
 
 void PageInfo::ContentSettingChangedViaPageInfo(ContentSettingsType type) {
   auto* settings = GetPageSpecificContentSettings();
-  if (!settings)
+  if (!settings) {
     return;
+  }
 
   return settings->ContentSettingChangedViaPageInfo(type);
 }
 
 int PageInfo::GetFirstPartyAllowedCookiesCount(const GURL& site_url) {
   auto* settings = GetPageSpecificContentSettings();
-  if (!settings)
+  if (!settings) {
     return 0;
+  }
   return settings->allowed_local_shared_objects().GetObjectCountForDomain(
       site_url);
 }
 
 int PageInfo::GetSitesWithAllowedCookiesAccessCount() {
   auto* settings = GetPageSpecificContentSettings();
-  if (!settings)
+  if (!settings) {
     return 0;
+  }
   return browsing_data::GetUniqueHostCount(
       settings->allowed_local_shared_objects(),
       *(settings->allowed_browsing_data_model()));
@@ -1693,17 +1708,27 @@
 int PageInfo::GetThirdPartySitesWithBlockedCookiesAccessCount(
     const GURL& site_url) {
   auto* settings = GetPageSpecificContentSettings();
-  if (!settings)
+  if (!settings) {
     return 0;
+  }
   return browsing_data::GetUniqueThirdPartyCookiesHostCount(
       site_url, settings->blocked_local_shared_objects(),
       *(settings->blocked_browsing_data_model()));
 }
 
+bool PageInfo::IsTrackingProtection3pcdEnabled() const {
+  return delegate_->IsTrackingProtection3pcdEnabled();
+}
+
+bool PageInfo::AreAllThirdPartyCookiesBlocked() const {
+  return delegate_->AreAllThirdPartyCookiesBlocked();
+}
+
 int PageInfo::GetFirstPartyBlockedCookiesCount(const GURL& site_url) {
   auto* settings = GetPageSpecificContentSettings();
-  if (!settings)
+  if (!settings) {
     return 0;
+  }
 
   return settings->blocked_local_shared_objects().GetObjectCountForDomain(
       site_url);
diff --git a/components/page_info/page_info.h b/components/page_info/page_info.h
index 2a10d89..67e84fd 100644
--- a/components/page_info/page_info.h
+++ b/components/page_info/page_info.h
@@ -346,6 +346,10 @@
 
   void PresentSitePermissionsForTesting() { PresentSitePermissions(); }
 
+  bool IsTrackingProtection3pcdEnabled() const;
+
+  bool AreAllThirdPartyCookiesBlocked() const;
+
  private:
   FRIEND_TEST_ALL_PREFIXES(PageInfoTest,
                            ShowInfoBarWhenAllowingThirdPartyCookies);
diff --git a/components/page_info/page_info_delegate.h b/components/page_info/page_info_delegate.h
index 0934729..6218fe1c 100644
--- a/components/page_info/page_info_delegate.h
+++ b/components/page_info/page_info_delegate.h
@@ -119,6 +119,9 @@
   virtual std::unique_ptr<
       content_settings::PageSpecificContentSettings::Delegate>
   GetPageSpecificContentSettingsDelegate() = 0;
+  virtual bool IsTrackingProtection3pcdEnabled() = 0;
+  virtual bool AreAllThirdPartyCookiesBlocked() = 0;
+
   virtual bool IsContentDisplayedInVrHeadset() = 0;
   virtual security_state::SecurityLevel GetSecurityLevel() = 0;
   virtual security_state::VisibleSecurityState GetVisibleSecurityState() = 0;
diff --git a/components/page_info_strings.grdp b/components/page_info_strings.grdp
index 9ea8fdba..3a42549e 100644
--- a/components/page_info_strings.grdp
+++ b/components/page_info_strings.grdp
@@ -715,17 +715,29 @@
 
   <!-- Cookies subpage -->
   <message name="IDS_PAGE_INFO_COOKIES_HEADER" desc="The header label of cookies subpage in Page Info bubble.">
-  Cookies and site data
+    Cookies and site data
   </message>
-  <message name="IDS_PAGE_INFO_TRACKING_PROTECTION_HEADER" desc="The header label of Tracking Protection subpage in Page Info bubble." translateable="false">
-  Tracking Protection
+  <message name="IDS_PAGE_INFO_TRACKING_PROTECTION_SITE_INFO_BUTTON_NAME" desc="A button in the Page Info bubble (which shows when you click the lock icon) that expands to another bubble detailing the user's Tracking protection settings.">
+    Tracking Protection
   </message>
-  <message name="IDS_PAGE_INFO_COOKIES_DESCRIPTION" desc="The descritpion of cookies in Cookies Subpage with placeholder for link to settings.">
+  <message name="IDS_PAGE_INFO_SUB_PAGE_VIEW_TRACKING_PROTECTION_HEADER" desc="The header label of Tracking Protection subview page.">
+    Tracking Protection
+  </message>
+  <message name="IDS_PAGE_INFO_COOKIES_DESCRIPTION" desc="The description of cookies in Cookies Subpage with placeholder for link to settings.">
     Cookies and other site data are used to remember you, for example to sign you in or to personalize ads. To manage cookies for all sites, see <ph name="SETTINGS">$1<ex>Settings</ex></ph>.
   </message>
+  <message name="IDS_PAGE_INFO_TRACKING_PROTECTION_DESCRIPTION" desc="Description text for the Tracking Protection subpage in the page info bubble. Contains a link to the Tracking Protection settings page.">
+    Chrome limits most sites from using third-party cookies to track you as you browse. Visit settings to <ph name="LINK">$1<ex>manage your tracking protections</ex></ph>.
+  </message>
+  <message name="IDS_PAGE_INFO_TRACKING_PROTECTION_BLOCKED_COOKIES_DESCRIPTION" desc="Description text for the Tracking Protection subpage in the page info bubble if all cookies are blocked. Contains a link to the Tracking Protection settings page.">
+    You blocked sites from using third-party cookies to track you as you browse. Visit settings to <ph name="LINK">$1<ex>manage your tracking protections</ex></ph>.
+  </message>
   <message name="IDS_PAGE_INFO_COOKIES_SETTINGS_LINK" desc="The text of the link to cookies settings.">
     Settings
   </message>
+  <message name="IDS_PAGE_INFO_TRACKING_PROTECTION_SETTINGS_LINK" desc="The text of the link to the tracking protection settings used within the tracking protection description.">
+    manage your tracking protections
+  </message>
   <message name="IDS_PAGE_INFO_BLOCK_THIRD_PARTY_COOKIES_TITLE" desc="The title on the blocking third-party cookies toggle in cookies subpage.">
     Block third-party cookies
   </message>
diff --git a/components/page_info_strings_grdp/IDS_PAGE_INFO_SUB_PAGE_VIEW_TRACKING_PROTECTION_HEADER.png.sha1 b/components/page_info_strings_grdp/IDS_PAGE_INFO_SUB_PAGE_VIEW_TRACKING_PROTECTION_HEADER.png.sha1
new file mode 100644
index 0000000..12f03d6d
--- /dev/null
+++ b/components/page_info_strings_grdp/IDS_PAGE_INFO_SUB_PAGE_VIEW_TRACKING_PROTECTION_HEADER.png.sha1
@@ -0,0 +1 @@
+4ffa00753119ee95b3fb7e9ab769b00fc701ea92
\ No newline at end of file
diff --git a/components/page_info_strings_grdp/IDS_PAGE_INFO_TRACKING_PROTECTION_BLOCKED_COOKIES_DESCRIPTION.png.sha1 b/components/page_info_strings_grdp/IDS_PAGE_INFO_TRACKING_PROTECTION_BLOCKED_COOKIES_DESCRIPTION.png.sha1
new file mode 100644
index 0000000..b0fb1ea
--- /dev/null
+++ b/components/page_info_strings_grdp/IDS_PAGE_INFO_TRACKING_PROTECTION_BLOCKED_COOKIES_DESCRIPTION.png.sha1
@@ -0,0 +1 @@
+7a56c9099867bc17a497f66a2026b693016d58dd
\ No newline at end of file
diff --git a/components/page_info_strings_grdp/IDS_PAGE_INFO_TRACKING_PROTECTION_DESCRIPTION.png.sha1 b/components/page_info_strings_grdp/IDS_PAGE_INFO_TRACKING_PROTECTION_DESCRIPTION.png.sha1
new file mode 100644
index 0000000..79a2af0c
--- /dev/null
+++ b/components/page_info_strings_grdp/IDS_PAGE_INFO_TRACKING_PROTECTION_DESCRIPTION.png.sha1
@@ -0,0 +1 @@
+e07c8f5f70739c14f3be9ec7678f95fff7082611
\ No newline at end of file
diff --git a/components/page_info_strings_grdp/IDS_PAGE_INFO_TRACKING_PROTECTION_SETTINGS_LINK.png.sha1 b/components/page_info_strings_grdp/IDS_PAGE_INFO_TRACKING_PROTECTION_SETTINGS_LINK.png.sha1
new file mode 100644
index 0000000..00fc549
--- /dev/null
+++ b/components/page_info_strings_grdp/IDS_PAGE_INFO_TRACKING_PROTECTION_SETTINGS_LINK.png.sha1
@@ -0,0 +1 @@
+21fcab096b9bbd472875e6f31f7453a13e1b1858
\ No newline at end of file
diff --git a/components/page_info_strings_grdp/IDS_PAGE_INFO_TRACKING_PROTECTION_SITE_INFO_BUTTON_NAME.png.sha1 b/components/page_info_strings_grdp/IDS_PAGE_INFO_TRACKING_PROTECTION_SITE_INFO_BUTTON_NAME.png.sha1
new file mode 100644
index 0000000..b2b7a0b
--- /dev/null
+++ b/components/page_info_strings_grdp/IDS_PAGE_INFO_TRACKING_PROTECTION_SITE_INFO_BUTTON_NAME.png.sha1
@@ -0,0 +1 @@
+7be6d436cb005a19b476467b766f6dc36e95a067
\ No newline at end of file