Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(401)

Unified Diff: chrome/browser/subresource_filter/subresource_filter_content_settings_manager.cc

Issue 2873123004: [subresource_filter] Duplicate settings notifications should not be logged (Closed)
Patch Set: shivanisha review Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/subresource_filter/subresource_filter_content_settings_manager.cc
diff --git a/chrome/browser/subresource_filter/subresource_filter_content_settings_manager.cc b/chrome/browser/subresource_filter/subresource_filter_content_settings_manager.cc
index 8aad111c45953db0e494dc0a949f165bfecd77c2..c74b94fbdbd399e271ddc66cecaf7d67aee85baf 100644
--- a/chrome/browser/subresource_filter/subresource_filter_content_settings_manager.cc
+++ b/chrome/browser/subresource_filter/subresource_filter_content_settings_manager.cc
@@ -56,6 +56,9 @@ SubresourceFilterContentSettingsManager::
profile, ServiceAccessType::EXPLICIT_ACCESS)) {
history_observer_.Add(history_service);
}
+
+ cached_global_setting_for_metrics_ = settings_map_->GetDefaultContentSetting(
+ CONTENT_SETTINGS_TYPE_SUBRESOURCE_FILTER, nullptr);
}
SubresourceFilterContentSettingsManager::
@@ -140,9 +143,17 @@ void SubresourceFilterContentSettingsManager::OnContentSettingChanged(
const ContentSettingsDetails details(primary_pattern, secondary_pattern,
content_type, resource_identifier);
+ DCHECK(!details.update_all_types());
+
if (details.update_all()) {
ContentSetting global_setting = settings_map_->GetDefaultContentSetting(
CONTENT_SETTINGS_TYPE_SUBRESOURCE_FILTER, nullptr);
+ // Ignore changes which retain the status quo. This also avoids logging
+ // metrics for changes which somehow notify this observer multiple times in
+ // a row. This shouldn't discount real user initiated changes.
+ if (global_setting == cached_global_setting_for_metrics_)
+ return;
+ cached_global_setting_for_metrics_ = global_setting;
if (global_setting == CONTENT_SETTING_BLOCK) {
ChromeSubresourceFilterClient::LogAction(
kActionContentSettingsBlockedGlobal);

Powered by Google App Engine
This is Rietveld 408576698