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

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

Issue 2184823007: Add a feature which, when enabled, blocks permissions after X prompt dismissals. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments Created 4 years, 4 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.h
diff --git a/chrome/browser/permissions/permission_decision_auto_blocker.h b/chrome/browser/permissions/permission_decision_auto_blocker.h
new file mode 100644
index 0000000000000000000000000000000000000000..2b02f5fe7b4d55d40186cf5604fe0ae046e46489
--- /dev/null
+++ b/chrome/browser/permissions/permission_decision_auto_blocker.h
@@ -0,0 +1,49 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_PERMISSIONS_PERMISSION_DECISION_AUTO_BLOCKER_H_
+#define CHROME_BROWSER_PERMISSIONS_PERMISSION_DECISION_AUTO_BLOCKER_H_
+
+#include "base/callback_forward.h"
+#include "base/macros.h"
+#include "content/public/browser/permission_type.h"
+#include "url/gurl.h"
+
+class GURL;
+class Profile;
+
+class PermissionDecisionAutoBlocker {
+ public:
+ static void RemoveCountsByUrl(Profile* profile,
+ base::Callback<bool(const GURL& url)> filter);
+
+ PermissionDecisionAutoBlocker();
+ bool ShouldChangeDismissalToBlock(Profile* profile,
+ const GURL& url,
+ content::PermissionType permission);
+
+ private:
+ friend class PermissionContextBaseTests;
+ friend class PermissionDecisionAutoBlockerUnitTest;
+
+ static const char kPromptDismissCountKey[];
+
+ // Returns the current number of dismissals for |permission| type at |url|.
+ // Exposed for testing.
+ int GetDismissalCount(Profile* profile,
+ const GURL& url,
+ content::PermissionType permission);
+
+ // Records that the user dismissed a permission prompt for type |permission|
+ // on |url| to a website setting. Returns the updated number of dismissals.
+ int RecordDismissalCount(Profile* profile,
+ const GURL& url,
+ content::PermissionType permission);
+
+ void UpdateFromVariations();
+
+ int prompt_dismissals_before_block_;
+};
+
+#endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_DECISION_AUTO_BLOCKER_H_

Powered by Google App Engine
This is Rietveld 408576698