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

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

Issue 2790473004: Permissions: Clear embargo if user changes an embargoed permission's setting. (Closed)
Patch Set: Created 3 years, 9 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 4dcc5fa94e37834bcfe3a68b5c09ad93c9e9c56f..02e72aead788cdf8b8ace9de2b6f6c66af2175d2 100644
--- a/chrome/browser/permissions/permission_decision_auto_blocker.cc
+++ b/chrome/browser/permissions/permission_decision_auto_blocker.cc
@@ -294,6 +294,29 @@ int PermissionDecisionAutoBlocker::RecordIgnore(
profile_);
}
+void PermissionDecisionAutoBlocker::RemoveEmbargoByURL(
+ const GURL& url,
+ ContentSettingsType permission) {
+ if (!PermissionUtil::IsPermission(permission))
+ return;
+
+ HostContentSettingsMap* map =
+ HostContentSettingsMapFactory::GetForProfile(profile_);
+ std::unique_ptr<base::DictionaryValue> dict = GetOriginDict(map, url);
+ base::DictionaryValue* permission_dict = GetOrCreatePermissionDict(
+ dict.get(), PermissionUtil::GetPermissionString(permission));
+ // Deleting non-existent entries will return a false value. Since it should be
+ // impossible for a permission to have been embargoed for two different
+ // reasons at the same time, check that exactly one deletion was successful.
+ DCHECK(permission_dict->RemoveWithoutPathExpansion(
dominickn 2017/04/03 01:35:30 I think you need to do this outside a DCHECK, or e
Patti Lor 2017/04/05 08:34:27 Oh, you're totally right. Thanks Dom, fixed.
+ kPermissionDismissalEmbargoKey, nullptr) !=
+ permission_dict->RemoveWithoutPathExpansion(
+ kPermissionBlacklistEmbargoKey, nullptr));
+ map->SetWebsiteSettingDefaultScope(
+ url, GURL(), CONTENT_SETTINGS_TYPE_PERMISSION_AUTOBLOCKER_DATA,
+ std::string(), std::move(dict));
+}
+
void PermissionDecisionAutoBlocker::RemoveCountsByUrl(
base::Callback<bool(const GURL& url)> filter) {
HostContentSettingsMap* map =

Powered by Google App Engine
This is Rietveld 408576698