| 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..3c8796c656d45dfca7a271825ef7ca7adf3ccf36 100644
|
| --- a/chrome/browser/permissions/permission_decision_auto_blocker.cc
|
| +++ b/chrome/browser/permissions/permission_decision_auto_blocker.cc
|
| @@ -14,6 +14,7 @@
|
| #include "chrome/browser/browser_process.h"
|
| #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
|
| #include "chrome/browser/permissions/permission_blacklist_client.h"
|
| +#include "chrome/browser/permissions/permission_uma_util.h"
|
| #include "chrome/browser/permissions/permission_util.h"
|
| #include "chrome/browser/profiles/incognito_helpers.h"
|
| #include "chrome/browser/profiles/profile.h"
|
| @@ -113,6 +114,20 @@ int GetActionCount(const GURL& url,
|
| return current_count;
|
| }
|
|
|
| +// Returns true if |url| has been embargoed from requesting |permission| for the
|
| +// reason corresponding to |key|.
|
| +bool WasPreviouslyEmbargoed(Profile* profile,
|
| + 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,7 +242,15 @@ bool PermissionDecisionAutoBlocker::RecordDismissAndEmbargo(
|
|
|
| if (base::FeatureList::IsEnabled(features::kBlockPromptsIfDismissedOften) &&
|
| current_dismissal_count >= g_prompt_dismissals_before_block) {
|
| + if (WasPreviouslyEmbargoed(profile_, url, permission,
|
| + kPermissionDismissalEmbargoKey)) {
|
| + PermissionUmaUtil::RecordRepeatedEmbargo(
|
| + PermissionEmbargoReason::REPEATED_DISMISSALS);
|
| + }
|
| +
|
| PlaceUnderEmbargo(permission, url, kPermissionDismissalEmbargoKey);
|
| + PermissionUmaUtil::RecordPermissionEmbargoReason(
|
| + PermissionEmbargoReason::REPEATED_DISMISSALS);
|
| return true;
|
| }
|
| return false;
|
| @@ -341,12 +364,19 @@ 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 (WasPreviouslyEmbargoed(profile_, request_origin, permission,
|
| + kPermissionBlacklistEmbargoKey)) {
|
| + PermissionUmaUtil::RecordRepeatedEmbargo(
|
| + PermissionEmbargoReason::PERMISSIONS_BLACKLISTING);
|
| + }
|
| +
|
| PlaceUnderEmbargo(permission, request_origin,
|
| kPermissionBlacklistEmbargoKey);
|
| + PermissionUmaUtil::RecordPermissionEmbargoReason(
|
| + PermissionEmbargoReason::PERMISSIONS_BLACKLISTING);
|
| }
|
| - callback.Run(should_be_embargoed /* permission blocked */);
|
| +
|
| + callback.Run(should_be_embargoed);
|
| }
|
|
|
| // static
|
|
|