[UB] Replace cookie counter with allow/block state in User Bypass
Most of this CL is cleaning up related logic + tests that are no longer
needed as a result
Bug: b:320711396
Change-Id: If905da974bc9a00cefdf4aa3f7826647310b25b9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5253722
Auto-Submit: Fiona Macintosh <fmacintosh@google.com>
Reviewed-by: Christian Dullweber <dullweber@chromium.org>
Commit-Queue: Fiona Macintosh <fmacintosh@google.com>
Cr-Commit-Position: refs/heads/main@{#1255034}
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index 36c0631b..a7af15d 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -4007,16 +4007,6 @@
<message name="IDS_COOKIE_CONTROLS_BUBBLE_SEND_FEEDBACK_FORM_PLACEHOLDER" desc="In the feedback text box accessible from the cookie controls bubble, this is the default text the user replaces with their feedback.">
Tell us why you allowed third-party cookies on this site
</message>
- <message name="IDS_COOKIE_CONTROLS_BUBBLE_BLOCKED_SITES_COUNT" desc="The count of sites that have been blocked from accessing third party cookies">
- {COUNT, plural,
- =1 {1 site blocked}
- other {# sites blocked}}
- </message>
- <message name="IDS_COOKIE_CONTROLS_BUBBLE_ALLOWED_SITES_COUNT" desc="The count of sites that have been allowed to access third party cookies">
- {COUNT, plural,
- =1 {1 site allowed}
- other {# sites allowed}}
- </message>
<message name="IDS_TRACKING_PROTECTION_BUBBLE_COOKIES_ALLOWED_LABEL" desc="A label for the third-party cookies toggle in the tracking protection bubble that tells the user third-party cookies are allowed.">
Allowed
</message>
diff --git a/chrome/app/generated_resources_grd/IDS_COOKIE_CONTROLS_BUBBLE_ALLOWED_SITES_COUNT.png.sha1 b/chrome/app/generated_resources_grd/IDS_COOKIE_CONTROLS_BUBBLE_ALLOWED_SITES_COUNT.png.sha1
deleted file mode 100644
index 9b278ea..0000000
--- a/chrome/app/generated_resources_grd/IDS_COOKIE_CONTROLS_BUBBLE_ALLOWED_SITES_COUNT.png.sha1
+++ /dev/null
@@ -1 +0,0 @@
-300d2fd3484a83b30cf39385de4f3a568eb7dde4
\ No newline at end of file
diff --git a/chrome/app/generated_resources_grd/IDS_COOKIE_CONTROLS_BUBBLE_BLOCKED_SITES_COUNT.png.sha1 b/chrome/app/generated_resources_grd/IDS_COOKIE_CONTROLS_BUBBLE_BLOCKED_SITES_COUNT.png.sha1
deleted file mode 100644
index 0a81616..0000000
--- a/chrome/app/generated_resources_grd/IDS_COOKIE_CONTROLS_BUBBLE_BLOCKED_SITES_COUNT.png.sha1
+++ /dev/null
@@ -1 +0,0 @@
-f3d8d08f1f10035335f94b5b0c9dc0a7830627dc
\ No newline at end of file
diff --git a/chrome/browser/ui/views/location_bar/cookie_controls/cookie_controls_bubble_unittest.cc b/chrome/browser/ui/views/location_bar/cookie_controls/cookie_controls_bubble_unittest.cc
index 0d71d05..354a4c05 100644
--- a/chrome/browser/ui/views/location_bar/cookie_controls/cookie_controls_bubble_unittest.cc
+++ b/chrome/browser/ui/views/location_bar/cookie_controls/cookie_controls_bubble_unittest.cc
@@ -457,8 +457,6 @@
TEST_F(CookieControlsBubbleViewControllerPre3pcdTest,
ThirdPartyCookiesBlocked) {
- const int kAllowedSitesCount = 2;
- const int kBlockedSitesCount = 3;
EXPECT_CALL(*mock_bubble_view(),
UpdateTitle(l10n_util::GetStringUTF16(
IDS_COOKIE_CONTROLS_BUBBLE_COOKIES_BLOCKED_TITLE)));
@@ -471,24 +469,19 @@
IDS_TRACKING_PROTECTION_BUBBLE_SITE_NOT_WORKING_DESCRIPTION)));
EXPECT_CALL(*mock_content_view(), SetFeedbackSectionVisibility(false));
EXPECT_CALL(*mock_content_view(), SetToggleIsOn(false));
- EXPECT_CALL(
- *mock_content_view(),
- SetToggleLabel(l10n_util::GetPluralStringFUTF16(
- IDS_COOKIE_CONTROLS_BUBBLE_BLOCKED_SITES_COUNT, kBlockedSitesCount)));
+ EXPECT_CALL(*mock_content_view(),
+ SetToggleLabel(l10n_util::GetStringUTF16(
+ IDS_TRACKING_PROTECTION_BUBBLE_COOKIES_BLOCKED_LABEL)));
EXPECT_CALL(*mock_content_view(), SetToggleIcon(testing::Field(
&gfx::VectorIcon::name,
features::IsChromeRefresh2023()
? views::kEyeCrossedRefreshIcon.name
: views::kEyeCrossedIcon.name)));
OnStatusChanged();
- view_controller()->OnSitesCountChanged(kAllowedSitesCount,
- kBlockedSitesCount);
}
TEST_F(CookieControlsBubbleViewControllerPre3pcdTest,
ThirdPartyCookiesAllowedPermanent) {
- const int kAllowedSitesCount = 2;
- const int kBlockedSitesCount = 3;
EXPECT_CALL(*mock_bubble_view(),
UpdateTitle(l10n_util::GetStringUTF16(
IDS_COOKIE_CONTROLS_BUBBLE_COOKIES_ALLOWED_TITLE)));
@@ -501,10 +494,9 @@
IDS_TRACKING_PROTECTION_BUBBLE_PERMANENT_ALLOWED_DESCRIPTION)));
EXPECT_CALL(*mock_content_view(), SetFeedbackSectionVisibility(true));
EXPECT_CALL(*mock_content_view(), SetToggleIsOn(true));
- EXPECT_CALL(
- *mock_content_view(),
- SetToggleLabel(l10n_util::GetPluralStringFUTF16(
- IDS_COOKIE_CONTROLS_BUBBLE_ALLOWED_SITES_COUNT, kAllowedSitesCount)));
+ EXPECT_CALL(*mock_content_view(),
+ SetToggleLabel(l10n_util::GetStringUTF16(
+ IDS_TRACKING_PROTECTION_BUBBLE_COOKIES_ALLOWED_LABEL)));
EXPECT_CALL(*mock_content_view(),
SetToggleIcon(testing::Field(&gfx::VectorIcon::name,
features::IsChromeRefresh2023()
@@ -512,14 +504,10 @@
: views::kEyeIcon.name)));
protections_on_ = false;
OnStatusChanged();
- view_controller()->OnSitesCountChanged(kAllowedSitesCount,
- kBlockedSitesCount);
}
TEST_F(CookieControlsBubbleViewControllerPre3pcdTest,
ThirdPartyCookiesAllowedTemporary) {
- const int kAllowedSitesCount = 2;
- const int kBlockedSitesCount = 3;
EXPECT_CALL(*mock_bubble_view(),
UpdateTitle(l10n_util::GetStringUTF16(
IDS_COOKIE_CONTROLS_BUBBLE_COOKIES_ALLOWED_TITLE)));
@@ -533,10 +521,9 @@
IDS_TRACKING_PROTECTION_BUBBLE_BLOCKING_RESTART_DESCRIPTION)));
EXPECT_CALL(*mock_content_view(), SetFeedbackSectionVisibility(true));
EXPECT_CALL(*mock_content_view(), SetToggleIsOn(true));
- EXPECT_CALL(
- *mock_content_view(),
- SetToggleLabel(l10n_util::GetPluralStringFUTF16(
- IDS_COOKIE_CONTROLS_BUBBLE_ALLOWED_SITES_COUNT, kAllowedSitesCount)));
+ EXPECT_CALL(*mock_content_view(),
+ SetToggleLabel(l10n_util::GetStringUTF16(
+ IDS_TRACKING_PROTECTION_BUBBLE_COOKIES_ALLOWED_LABEL)));
EXPECT_CALL(*mock_content_view(),
SetToggleIcon(testing::Field(&gfx::VectorIcon::name,
features::IsChromeRefresh2023()
@@ -544,8 +531,6 @@
: views::kEyeIcon.name)));
protections_on_ = false;
OnStatusChanged(kDaysToExpiration);
- view_controller()->OnSitesCountChanged(kAllowedSitesCount,
- kBlockedSitesCount);
}
class CookieControlsBubbleViewImplTest : public TestWithBrowserView {
diff --git a/chrome/browser/ui/views/location_bar/cookie_controls/cookie_controls_bubble_view_controller.cc b/chrome/browser/ui/views/location_bar/cookie_controls/cookie_controls_bubble_view_controller.cc
index 5bc18e2..8245959 100644
--- a/chrome/browser/ui/views/location_bar/cookie_controls/cookie_controls_bubble_view_controller.cc
+++ b/chrome/browser/ui/views/location_bar/cookie_controls/cookie_controls_bubble_view_controller.cc
@@ -151,6 +151,8 @@
label_title, l10n_util::GetStringUTF16(label_description));
bubble_view_->GetContentView()->SetToggleIsOn(true);
bubble_view_->GetContentView()->SetToggleIcon(GetToggleIcon(true));
+ bubble_view_->GetContentView()->SetToggleLabel(l10n_util::GetStringUTF16(
+ IDS_TRACKING_PROTECTION_BUBBLE_COOKIES_ALLOWED_LABEL));
}
void CookieControlsBubbleViewController::ApplyThirdPartyCookiesBlockedState() {
@@ -165,6 +167,10 @@
IDS_TRACKING_PROTECTION_BUBBLE_SITE_NOT_WORKING_DESCRIPTION));
bubble_view_->GetContentView()->SetToggleIsOn(false);
bubble_view_->GetContentView()->SetToggleIcon(GetToggleIcon(false));
+ bubble_view_->GetContentView()->SetToggleLabel(l10n_util::GetStringUTF16(
+ blocking_status_ == CookieBlocking3pcdStatus::kLimited
+ ? IDS_TRACKING_PROTECTION_BUBBLE_COOKIES_LIMITED_LABEL
+ : IDS_TRACKING_PROTECTION_BUBBLE_COOKIES_BLOCKED_LABEL));
}
CookieControlsBubbleViewController::~CookieControlsBubbleViewController() =
@@ -207,8 +213,7 @@
case CookieControlsEnforcement::kEnforcedByCookieSetting:
// In 3PCD, tell the user if they allowed the current site in settings.
bubble_view_->GetContentView()->SetContentLabelsVisible(
- enforcement == CookieControlsEnforcement::kEnforcedByCookieSetting &&
- blocking_status != CookieBlocking3pcdStatus::kNotIn3pcd);
+ enforcement == CookieControlsEnforcement::kEnforcedByCookieSetting);
bubble_view_->GetContentView()->SetFeedbackSectionVisibility(false);
bubble_view_->GetContentView()->SetToggleVisible(false);
bubble_view_->GetContentView()->SetEnforcedIcon(
@@ -219,41 +224,6 @@
bubble_view_->GetContentView()->SetEnforcedIconVisible(true);
break;
}
- // If we're in 3PCD, update toggle label based on `protections_on_`.
- if (blocking_status_ != CookieBlocking3pcdStatus::kNotIn3pcd) {
- int label;
- if (protections_on_) {
- label = blocking_status_ == CookieBlocking3pcdStatus::kAll
- ? IDS_TRACKING_PROTECTION_BUBBLE_COOKIES_BLOCKED_LABEL
- : IDS_TRACKING_PROTECTION_BUBBLE_COOKIES_LIMITED_LABEL;
- } else {
- label = IDS_TRACKING_PROTECTION_BUBBLE_COOKIES_ALLOWED_LABEL;
- }
- bubble_view_->GetContentView()->SetToggleLabel(
- l10n_util::GetStringUTF16(label));
- }
-}
-
-void CookieControlsBubbleViewController::OnSitesCountChanged(
- int allowed_third_party_sites_count,
- int blocked_third_party_sites_count) {
- // We don't surface site counts in the UB bubble for 3PCD instead we will set
- // the label in `OnStatusChange`.
- if (blocking_status_ != CookieBlocking3pcdStatus::kNotIn3pcd) {
- return;
- }
- std::u16string label;
-
- if (protections_on_) {
- label = l10n_util::GetPluralStringFUTF16(
- IDS_COOKIE_CONTROLS_BUBBLE_BLOCKED_SITES_COUNT,
- blocked_third_party_sites_count);
- } else {
- label = l10n_util::GetPluralStringFUTF16(
- IDS_COOKIE_CONTROLS_BUBBLE_ALLOWED_SITES_COUNT,
- allowed_third_party_sites_count);
- }
- bubble_view_->GetContentView()->SetToggleLabel(label);
}
void CookieControlsBubbleViewController::OnBreakageConfidenceLevelChanged(
diff --git a/chrome/browser/ui/views/location_bar/cookie_controls/cookie_controls_bubble_view_controller.h b/chrome/browser/ui/views/location_bar/cookie_controls/cookie_controls_bubble_view_controller.h
index 640c98e9..a459a4e 100644
--- a/chrome/browser/ui/views/location_bar/cookie_controls/cookie_controls_bubble_view_controller.h
+++ b/chrome/browser/ui/views/location_bar/cookie_controls/cookie_controls_bubble_view_controller.h
@@ -41,8 +41,6 @@
CookieControlsEnforcement enforcement,
CookieBlocking3pcdStatus blocking_status,
base::Time expiration) override;
- void OnSitesCountChanged(int allowed_third_party_sites_count,
- int blocked_third_party_sites_count) override;
void OnBreakageConfidenceLevelChanged(
CookieControlsBreakageConfidenceLevel level) override;
void OnFinishedPageReloadWithChangedSettings() override;
diff --git a/chrome/browser/ui/views/location_bar/cookie_controls/cookie_controls_icon_view.cc b/chrome/browser/ui/views/location_bar/cookie_controls/cookie_controls_icon_view.cc
index 7f67ff4..41452d9 100644
--- a/chrome/browser/ui/views/location_bar/cookie_controls/cookie_controls_icon_view.cc
+++ b/chrome/browser/ui/views/location_bar/cookie_controls/cookie_controls_icon_view.cc
@@ -239,12 +239,6 @@
}
}
-void CookieControlsIconView::OnSitesCountChanged(
- int allowed_third_party_sites_count,
- int blocked_third_party_sites_count) {
- // The icon doesn't update if sites count changes.
-}
-
// TODO(b/317883749): Remove usage of this function and
// `CookiesControlsBreakageConfidenceLevel`.
void CookieControlsIconView::OnBreakageConfidenceLevelChanged(
diff --git a/chrome/browser/ui/views/location_bar/cookie_controls/cookie_controls_icon_view.h b/chrome/browser/ui/views/location_bar/cookie_controls/cookie_controls_icon_view.h
index 2078b90d..8ffe211e 100644
--- a/chrome/browser/ui/views/location_bar/cookie_controls/cookie_controls_icon_view.h
+++ b/chrome/browser/ui/views/location_bar/cookie_controls/cookie_controls_icon_view.h
@@ -33,8 +33,6 @@
~CookieControlsIconView() override;
// CookieControlsObserver:
- void OnSitesCountChanged(int allowed_third_party_sites_count,
- int blocked_third_party_sites_count) override;
void OnBreakageConfidenceLevelChanged(
CookieControlsBreakageConfidenceLevel level) override;
void OnUserBypassIconStatusChanged(
diff --git a/chrome/browser/ui/views/page_info/page_info_bubble_view_dialog_browsertest.cc b/chrome/browser/ui/views/page_info/page_info_bubble_view_dialog_browsertest.cc
index 529c269..73f382f5 100644
--- a/chrome/browser/ui/views/page_info/page_info_bubble_view_dialog_browsertest.cc
+++ b/chrome/browser/ui/views/page_info/page_info_bubble_view_dialog_browsertest.cc
@@ -751,8 +751,6 @@
PageInfoUI::CookiesNewInfo cookie_info;
cookie_info.allowed_sites_count = 9;
- cookie_info.allowed_third_party_sites_count = 5;
- cookie_info.blocked_third_party_sites_count = 8;
cookie_info.enforcement = enforcement_;
cookie_info.protections_on = protections_on_;
cookie_info.controls_visible = controls_visible_;
diff --git a/chrome/browser/ui/views/page_info/page_info_bubble_view_unittest.cc b/chrome/browser/ui/views/page_info/page_info_bubble_view_unittest.cc
index 8511273..bf8824c1 100644
--- a/chrome/browser/ui/views/page_info/page_info_bubble_view_unittest.cc
+++ b/chrome/browser/ui/views/page_info/page_info_bubble_view_unittest.cc
@@ -979,8 +979,6 @@
// Create a fake cookies info.
PageInfoUI::CookiesNewInfo cookies;
cookies.allowed_sites_count = 10;
- cookies.allowed_third_party_sites_count = 8;
- cookies.blocked_third_party_sites_count = 32;
cookies.protections_on = true;
cookies.enforcement = CookieControlsEnforcement::kNoEnforcement;
cookies.blocking_status = CookieBlocking3pcdStatus::kNotIn3pcd;
diff --git a/chrome/browser/ui/views/page_info/page_info_cookies_content_view_unittest.cc b/chrome/browser/ui/views/page_info/page_info_cookies_content_view_unittest.cc
index d67a0c4..c84ad6d1 100644
--- a/chrome/browser/ui/views/page_info/page_info_cookies_content_view_unittest.cc
+++ b/chrome/browser/ui/views/page_info/page_info_cookies_content_view_unittest.cc
@@ -45,8 +45,6 @@
PageInfoCookiesContentView::CookiesNewInfo DefaultCookieInfoForTests(
int days_to_expiration = 0) {
PageInfoCookiesContentView::CookiesNewInfo cookie_info;
- cookie_info.blocked_third_party_sites_count = 8;
- cookie_info.allowed_third_party_sites_count = 3;
cookie_info.allowed_sites_count = 10;
// base::Time() represents a null when used as an expiration.
cookie_info.expiration =
diff --git a/components/content_settings/browser/ui/cookie_controls_controller.cc b/components/content_settings/browser/ui/cookie_controls_controller.cc
index 53969d9b..12d660e 100644
--- a/components/content_settings/browser/ui/cookie_controls_controller.cc
+++ b/components/content_settings/browser/ui/cookie_controls_controller.cc
@@ -139,7 +139,6 @@
auto status = GetStatus(web_contents);
int third_party_allowed_sites = GetAllowedThirdPartyCookiesSitesCount();
int third_party_blocked_sites = GetBlockedThirdPartyCookiesSitesCount();
- int bounce_count = GetStatefulBounceCount();
for (auto& observer : observers_) {
observer.OnStatusChanged(status.status, status.controls_visible,
@@ -149,9 +148,10 @@
third_party_blocked_sites);
observer.OnUserBypassIconStatusChanged(
status.controls_visible, status.protections_on, status.blocking_status);
- observer.OnBreakageConfidenceLevelChanged(GetConfidenceLevel(
- status.status, status.enforcement, third_party_allowed_sites,
- third_party_blocked_sites, bounce_count));
+ observer.OnBreakageConfidenceLevelChanged(
+ GetConfidenceLevel(status.status, status.enforcement,
+ SiteDataAccessed(third_party_allowed_sites,
+ third_party_blocked_sites)));
}
}
@@ -243,9 +243,7 @@
CookieControlsController::GetConfidenceLevel(
CookieControlsStatus status,
CookieControlsEnforcement enforcement,
- int allowed_sites,
- int blocked_sites,
- int bounce_count) {
+ bool site_data_accessed) {
// If 3PC cookies are not blocked by default:
switch (status) {
case CookieControlsStatus::kDisabled:
@@ -275,7 +273,7 @@
// blocked counts, since the breakage might be related to storage
// partitioning. Partitioned site will be allowed to access partitioned
// storage.
- if (allowed_sites + blocked_sites + bounce_count == 0) {
+ if (!site_data_accessed) {
return CookieControlsBreakageConfidenceLevel::kLow;
}
@@ -382,11 +380,11 @@
CookieControlsBreakageConfidenceLevel
CookieControlsController::GetBreakageConfidenceLevel() {
auto status = GetStatus(GetWebContents());
- int allowed_sites = GetAllowedSitesCount();
- int blocked_sites = GetBlockedSitesCount();
- int bounce_count = GetStatefulBounceCount();
- return GetConfidenceLevel(status.status, status.enforcement, allowed_sites,
- blocked_sites, bounce_count);
+ int third_party_allowed_sites = GetAllowedThirdPartyCookiesSitesCount();
+ int third_party_blocked_sites = GetBlockedThirdPartyCookiesSitesCount();
+ return GetConfidenceLevel(
+ status.status, status.enforcement,
+ SiteDataAccessed(third_party_allowed_sites, third_party_blocked_sites));
}
CookieControlsStatus CookieControlsController::GetCookieControlsStatus() {
@@ -394,53 +392,6 @@
return status.status;
}
-int CookieControlsController::GetAllowedCookieCount() const {
- auto* pscs = content_settings::PageSpecificContentSettings::GetForPage(
- GetWebContents()->GetPrimaryPage());
- if (pscs) {
- return pscs->allowed_local_shared_objects().GetObjectCount() +
- pscs->allowed_browsing_data_model()->size();
- } else {
- return 0;
- }
-}
-int CookieControlsController::GetBlockedCookieCount() const {
- auto* pscs = content_settings::PageSpecificContentSettings::GetForPage(
- GetWebContents()->GetPrimaryPage());
- if (pscs) {
- return pscs->blocked_local_shared_objects().GetObjectCount() +
- pscs->blocked_browsing_data_model()->size();
- } else {
- return 0;
- }
-}
-
-int CookieControlsController::GetAllowedSitesCount() const {
- // TODO(crbug.com/1446230): The method should return the number of allowed
- // *third-party* sites (and take BDM into account).
- auto* pscs = content_settings::PageSpecificContentSettings::GetForPage(
- GetWebContents()->GetPrimaryPage());
- if (!pscs) {
- return 0;
- }
- return browsing_data::GetUniqueHostCount(
- pscs->allowed_local_shared_objects(),
- *(pscs->allowed_browsing_data_model()));
-}
-
-int CookieControlsController::GetBlockedSitesCount() const {
- // TODO(crbug.com/1446230): The method should return the number of blocked
- // *third-party* sites (and take BDM into account).
- auto* pscs = content_settings::PageSpecificContentSettings::GetForPage(
- GetWebContents()->GetPrimaryPage());
- if (!pscs) {
- return 0;
- }
- return browsing_data::GetUniqueHostCount(
- pscs->blocked_local_shared_objects(),
- *(pscs->blocked_browsing_data_model()));
-}
-
int CookieControlsController::GetAllowedThirdPartyCookiesSitesCount() const {
auto* pscs = content_settings::PageSpecificContentSettings::GetForPage(
GetWebContents()->GetPrimaryPage());
@@ -477,18 +428,25 @@
}
}
+bool CookieControlsController::SiteDataAccessed(int third_party_allowed_sites,
+ int third_party_blocked_sites) {
+ return third_party_allowed_sites + third_party_blocked_sites +
+ GetStatefulBounceCount() !=
+ 0;
+}
+
void CookieControlsController::PresentBlockedCookieCounter() {
auto status = GetStatus(GetWebContents());
int third_party_allowed_sites = GetAllowedThirdPartyCookiesSitesCount();
int third_party_blocked_sites = GetBlockedThirdPartyCookiesSitesCount();
- int bounce_count = GetStatefulBounceCount();
for (auto& observer : observers_) {
observer.OnSitesCountChanged(third_party_allowed_sites,
third_party_blocked_sites);
- observer.OnBreakageConfidenceLevelChanged(GetConfidenceLevel(
- status.status, status.enforcement, third_party_allowed_sites,
- third_party_blocked_sites, bounce_count));
+ observer.OnBreakageConfidenceLevelChanged(
+ GetConfidenceLevel(status.status, status.enforcement,
+ SiteDataAccessed(third_party_allowed_sites,
+ third_party_blocked_sites)));
}
}
@@ -525,14 +483,11 @@
return;
}
- int allowed_sites = GetAllowedSitesCount();
- int blocked_sites = GetBlockedSitesCount();
- int bounce_count = GetStatefulBounceCount();
-
for (auto& observer : observers_) {
- observer.OnBreakageConfidenceLevelChanged(
- GetConfidenceLevel(status.status, status.enforcement, allowed_sites,
- blocked_sites, bounce_count));
+ observer.OnBreakageConfidenceLevelChanged(GetConfidenceLevel(
+ status.status, status.enforcement,
+ SiteDataAccessed(GetAllowedThirdPartyCookiesSitesCount(),
+ GetBlockedThirdPartyCookiesSitesCount())));
}
}
@@ -596,10 +551,10 @@
"Privacy.CookieControlsActivated.SiteEngagementScore",
GetSiteEngagementScore(), 100);
- int allowed_sites = GetAllowedSitesCount();
- int blocked_sites = GetBlockedSitesCount();
- auto site_data_access_type =
- GetSiteDataAccessType(allowed_sites, blocked_sites);
+ int third_party_allowed_sites = GetAllowedThirdPartyCookiesSitesCount();
+ int third_party_blocked_sites = GetBlockedThirdPartyCookiesSitesCount();
+ auto site_data_access_type = GetSiteDataAccessType(third_party_allowed_sites,
+ third_party_blocked_sites);
base::UmaHistogramEnumeration(
"Privacy.CookieControlsActivated.SiteDataAccessType",
site_data_access_type);
diff --git a/components/content_settings/browser/ui/cookie_controls_controller.h b/components/content_settings/browser/ui/cookie_controls_controller.h
index 71aaa7d..2e43fa9 100644
--- a/components/content_settings/browser/ui/cookie_controls_controller.h
+++ b/components/content_settings/browser/ui/cookie_controls_controller.h
@@ -150,9 +150,7 @@
CookieControlsBreakageConfidenceLevel GetConfidenceLevel(
CookieControlsStatus status,
CookieControlsEnforcement enforcement,
- int allowed_sites,
- int blocked_sites,
- int bounce_count);
+ bool site_data_accessed);
bool HasOriginSandboxedTopLevelDocument() const;
@@ -163,21 +161,9 @@
void OnPageFinishedLoading();
- // Returns the number of allowed cookies.
- int GetAllowedCookieCount() const;
-
- // Returns the number of blocked cookies.
- int GetBlockedCookieCount() const;
-
// Returns the number of stateful bounces leading to this page.
int GetStatefulBounceCount() const;
- // Returns the number of allowed sites.
- int GetAllowedSitesCount() const;
-
- // Returns the number of blocked sites.
- int GetBlockedSitesCount() const;
-
// Returns the number of allowed third-party sites with cookies.
int GetAllowedThirdPartyCookiesSitesCount() const;
@@ -189,6 +175,9 @@
// Record metrics when third-party cookies are allowed.
void RecordActivationMetrics();
+ bool SiteDataAccessed(int third_party_allowed_sites,
+ int third_party_blocked_sites);
+
content::WebContents* GetWebContents() const;
std::unique_ptr<TabObserver> tab_observer_;
diff --git a/components/content_settings/browser/ui/cookie_controls_view.h b/components/content_settings/browser/ui/cookie_controls_view.h
index 2eff2b1..3f89ccdf 100644
--- a/components/content_settings/browser/ui/cookie_controls_view.h
+++ b/components/content_settings/browser/ui/cookie_controls_view.h
@@ -44,7 +44,7 @@
// other than 3PCB to why a site is blocked or allowed (ex. site data
// exceptions).
virtual void OnSitesCountChanged(int allowed_third_party_sites_count,
- int blocked_third_party_sites_count) = 0;
+ int blocked_third_party_sites_count) {}
// Called wherever the site breakage confidence level changes. It takes into
// account blocked third-party cookie access, exceptions lifecycle, site
diff --git a/components/page_info/page_info.cc b/components/page_info/page_info.cc
index dc8ae730..5af5aea 100644
--- a/components/page_info/page_info.cc
+++ b/components/page_info/page_info.cc
@@ -344,16 +344,6 @@
}
}
-void PageInfo::OnSitesCountChanged(int allowed_third_party_sites_count,
- int blocked_third_party_sites_count) {
- if (allowed_third_party_sites_count_ != allowed_third_party_sites_count ||
- blocked_third_party_sites_count_ != blocked_third_party_sites_count) {
- allowed_third_party_sites_count_ = allowed_third_party_sites_count;
- blocked_third_party_sites_count_ = blocked_third_party_sites_count;
- PresentSiteData(base::DoNothing());
- }
-}
-
void PageInfo::OnBreakageConfidenceLevelChanged(
CookieControlsBreakageConfidenceLevel level) {
if (cookie_controls_confidence_ != level) {
@@ -1478,14 +1468,6 @@
PageInfoUI::CookiesNewInfo cookies_info;
cookies_info.allowed_sites_count = GetSitesWithAllowedCookiesAccessCount();
- // TODO(crbug.com/1446230): Clean up and remove the fallback after the feature
- // was launched. If blocked_third_party_sites_count_ isn't set, use fallback
- // and count the sites.
- cookies_info.blocked_third_party_sites_count =
- blocked_third_party_sites_count_.value_or(
- GetThirdPartySitesWithBlockedCookiesAccessCount(site_url_));
- cookies_info.allowed_third_party_sites_count =
- allowed_third_party_sites_count_.value_or(0);
#if !BUILDFLAG(IS_ANDROID)
if (base::FeatureList::IsEnabled(
diff --git a/components/page_info/page_info.h b/components/page_info/page_info.h
index 33bc628..02166de9 100644
--- a/components/page_info/page_info.h
+++ b/components/page_info/page_info.h
@@ -361,8 +361,6 @@
CookieControlsEnforcement enforcement,
CookieBlocking3pcdStatus blocking_status,
base::Time expiration) override;
- void OnSitesCountChanged(int allowed_third_party_sites_count,
- int blocked_third_party_sites_count) override;
void OnBreakageConfidenceLevelChanged(
CookieControlsBreakageConfidenceLevel level) override;
@@ -556,12 +554,6 @@
CookieControlsBreakageConfidenceLevel cookie_controls_confidence_ =
CookieControlsBreakageConfidenceLevel::kUninitialized;
- // The number of third-party sites blocked from accessing storage.
- std::optional<int> blocked_third_party_sites_count_;
-
- // The number of third-party sites allowed to access storage.
- std::optional<int> allowed_third_party_sites_count_;
-
bool is_subscribed_to_permission_change_for_testing = false;
base::WeakPtrFactory<PageInfo> weak_factory_{this};