OLD | NEW |
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 Loading... |
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 Loading... |
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_ |
OLD | NEW |