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

Side by Side Diff: chrome/browser/permissions/permission_decision_auto_blocker.h

Issue 2790493002: Implement permissions embargo for prompts which are repeatedly ignored. (Closed)
Patch Set: Not for plugins Created 3 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_PERMISSIONS_PERMISSION_DECISION_AUTO_BLOCKER_H_ 5 #ifndef CHROME_BROWSER_PERMISSIONS_PERMISSION_DECISION_AUTO_BLOCKER_H_
6 #define CHROME_BROWSER_PERMISSIONS_PERMISSION_DECISION_AUTO_BLOCKER_H_ 6 #define CHROME_BROWSER_PERMISSIONS_PERMISSION_DECISION_AUTO_BLOCKER_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 // Returns the current number of dismisses recorded for |permission| type at 78 // Returns the current number of dismisses recorded for |permission| type at
79 // |url|. 79 // |url|.
80 int GetDismissCount(const GURL& url, ContentSettingsType permission); 80 int GetDismissCount(const GURL& url, ContentSettingsType permission);
81 81
82 // Returns the current number of ignores recorded for |permission| 82 // Returns the current number of ignores recorded for |permission|
83 // type at |url|. 83 // type at |url|.
84 int GetIgnoreCount(const GURL& url, ContentSettingsType permission); 84 int GetIgnoreCount(const GURL& url, ContentSettingsType permission);
85 85
86 // Records that a dismissal of a prompt for |permission| was made. If the 86 // Records that a dismissal of a prompt for |permission| was made. If the
87 // total number of dismissals exceeds a threshhold and 87 // total number of dismissals exceeds a threshhold and
88 // features::kBlockPromptsIfDismissedOften is enabled it will place |url| 88 // features::kBlockPromptsIfDismissedOften is enabled, it will place |url|
89 // under embargo for |permission|. 89 // under embargo for |permission|.
90 bool RecordDismissAndEmbargo(const GURL& url, ContentSettingsType permission); 90 bool RecordDismissAndEmbargo(const GURL& url, ContentSettingsType permission);
91 91
92 // Records that an ignore of a prompt for |permission| was made. 92 // Records that an ignore of a prompt for |permission| was made. If the total
93 int RecordIgnore(const GURL& url, ContentSettingsType permission); 93 // number of ignores exceeds a threshold and
94 // features::kBlockPromptsIfIgnoredOften is enabled, it will place |url| under
95 // embargo for |permission|.
96 bool RecordIgnoreAndEmbargo(const GURL& url, ContentSettingsType permission);
94 97
95 // Removes any recorded counts for urls which match |filter|. 98 // Removes any recorded counts for urls which match |filter|.
96 void RemoveCountsByUrl(base::Callback<bool(const GURL& url)> filter); 99 void RemoveCountsByUrl(base::Callback<bool(const GURL& url)> filter);
97 100
98 private: 101 private:
99 friend class PermissionContextBaseTests; 102 friend class PermissionContextBaseTests;
100 friend class PermissionDecisionAutoBlockerUnitTest; 103 friend class PermissionDecisionAutoBlockerUnitTest;
101 104
102 explicit PermissionDecisionAutoBlocker(Profile* profile); 105 explicit PermissionDecisionAutoBlocker(Profile* profile);
103 ~PermissionDecisionAutoBlocker() override; 106 ~PermissionDecisionAutoBlocker() override;
(...skipping 12 matching lines...) Expand all
116 void SetSafeBrowsingDatabaseManagerAndTimeoutForTesting( 119 void SetSafeBrowsingDatabaseManagerAndTimeoutForTesting(
117 scoped_refptr<safe_browsing::SafeBrowsingDatabaseManager> db_manager, 120 scoped_refptr<safe_browsing::SafeBrowsingDatabaseManager> db_manager,
118 int timeout); 121 int timeout);
119 122
120 void SetClockForTesting(std::unique_ptr<base::Clock> clock); 123 void SetClockForTesting(std::unique_ptr<base::Clock> clock);
121 124
122 // Keys used for storing count data in a website setting. 125 // Keys used for storing count data in a website setting.
123 static const char kPromptDismissCountKey[]; 126 static const char kPromptDismissCountKey[];
124 static const char kPromptIgnoreCountKey[]; 127 static const char kPromptIgnoreCountKey[];
125 static const char kPermissionDismissalEmbargoKey[]; 128 static const char kPermissionDismissalEmbargoKey[];
129 static const char kPermissionIgnoreEmbargoKey[];
126 static const char kPermissionBlacklistEmbargoKey[]; 130 static const char kPermissionBlacklistEmbargoKey[];
127 131
128 Profile* profile_; 132 Profile* profile_;
129 scoped_refptr<safe_browsing::SafeBrowsingDatabaseManager> db_manager_; 133 scoped_refptr<safe_browsing::SafeBrowsingDatabaseManager> db_manager_;
130 134
131 // Timeout in ms. 135 // Timeout in ms.
132 int safe_browsing_timeout_; 136 int safe_browsing_timeout_;
133 137
134 std::unique_ptr<base::Clock> clock_; 138 std::unique_ptr<base::Clock> clock_;
135 139
136 DISALLOW_IMPLICIT_CONSTRUCTORS(PermissionDecisionAutoBlocker); 140 DISALLOW_IMPLICIT_CONSTRUCTORS(PermissionDecisionAutoBlocker);
137 }; 141 };
138 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_DECISION_AUTO_BLOCKER_H_ 142 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_DECISION_AUTO_BLOCKER_H_
OLDNEW
« no previous file with comments | « chrome/browser/permissions/permission_context_base.cc ('k') | chrome/browser/permissions/permission_decision_auto_blocker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698