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

Unified Diff: chrome/browser/permissions/permission_decision_auto_blocker.cc

Issue 2651163002: Add UMA for autoblocking and embargoing. (Closed)
Patch Set: Created 3 years, 11 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/permissions/permission_decision_auto_blocker.cc
diff --git a/chrome/browser/permissions/permission_decision_auto_blocker.cc b/chrome/browser/permissions/permission_decision_auto_blocker.cc
index 97834772a53a020cf6ae1aa3ad7c76d6e52b7bb1..db566a204832f2cf2a3c090b53978fdd6583eb1e 100644
--- a/chrome/browser/permissions/permission_decision_auto_blocker.cc
+++ b/chrome/browser/permissions/permission_decision_auto_blocker.cc
@@ -113,6 +113,18 @@ int GetActionCount(const GURL& url,
return current_count;
}
+bool PreviouslyEmbargoed(Profile* profile,
dominickn 2017/01/27 06:05:47 Call this WasPreviouslyEmbargoed. Add a comment sa
meredithl 2017/01/29 23:48:29 Done.
+ const GURL& url,
+ content::PermissionType permission,
+ const char* key) {
+ HostContentSettingsMap* map =
+ HostContentSettingsMapFactory::GetForProfile(profile);
+ std::unique_ptr<base::DictionaryValue> dict = GetOriginDict(map, url);
+ base::DictionaryValue* permission_dict = GetOrCreatePermissionDict(
+ dict.get(), PermissionUtil::GetPermissionString(permission));
+ return permission_dict->HasKey(key);
+}
+
} // namespace
// PermissionDecisionAutoBlocker::Factory --------------------------------------
@@ -227,9 +239,18 @@ bool PermissionDecisionAutoBlocker::RecordDismissAndEmbargo(
if (base::FeatureList::IsEnabled(features::kBlockPromptsIfDismissedOften) &&
current_dismissal_count >= g_prompt_dismissals_before_block) {
+ if (PreviouslyEmbargoed(profile_, url, permission,
+ kPermissionDismissalEmbargoKey)) {
+ PermissionUmaUtil::RecordRepeatedEmbargo(
+ PermissionEmbargoReason::REPEATED_DISMISSALS);
+ }
+
PlaceUnderEmbargo(permission, url, kPermissionDismissalEmbargoKey);
+ PermissionUmaUtil::RecordPermissionEmbargoReason(
+ PermissionEmbargoReason::REPEATED_DISMISSALS);
return true;
}
+
dominickn 2017/01/27 06:05:47 Nit: probably don't need this extra newline
meredithl 2017/01/29 23:48:29 Done.
return false;
}
@@ -341,12 +362,22 @@ void PermissionDecisionAutoBlocker::CheckSafeBrowsingResult(
base::Callback<void(bool)> callback,
bool should_be_embargoed) {
if (should_be_embargoed) {
- // Requesting site is blacklisted for this permission, update the content
- // setting to place it under embargo.
+ if (PreviouslyEmbargoed(profile_, request_origin, permission,
+ kPermissionBlacklistEmbargoKey)) {
+ PermissionUmaUtil::RecordRepeatedEmbargo(
+ PermissionEmbargoReason::PERMISSIONS_BLACKLISTING);
+ }
+
PlaceUnderEmbargo(permission, request_origin,
kPermissionBlacklistEmbargoKey);
+ PermissionUmaUtil::RecordPermissionEmbargoReason(
+ PermissionEmbargoReason::PERMISSIONS_BLACKLISTING);
+ } else {
+ PermissionUmaUtil::RecordPermissionEmbargoReason(
dominickn 2017/01/27 06:05:47 Will this double count since you're calling Record
meredithl 2017/01/29 23:48:29 Hmm, I believe so. Imo that should have been picke
dominickn 2017/01/30 00:06:20 You don't actually have any test which checks the
meredithl 2017/01/30 00:34:33 I do a check of the histograms in Permission Conte
dominickn 2017/01/30 00:42:36 Right, but those tests don't have a safe browsing
meredithl 2017/01/30 02:04:47 Okay, I've added an extra test in PDAB to check th
+ PermissionEmbargoReason::NOT_EMBARGOED);
}
- callback.Run(should_be_embargoed /* permission blocked */);
+
+ callback.Run(should_be_embargoed);
}
// static

Powered by Google App Engine
This is Rietveld 408576698