Chromium Code Reviews| 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_forward.h" | 8 #include "base/callback_forward.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "content/public/browser/permission_type.h" | 10 #include "content/public/browser/permission_type.h" |
| 11 #include "url/gurl.h" | 11 #include "url/gurl.h" |
| 12 | 12 |
| 13 class GURL; | 13 class GURL; |
| 14 class Profile; | 14 class Profile; |
| 15 | 15 |
| 16 class PermissionDecisionAutoBlocker { | 16 class PermissionDecisionAutoBlocker { |
| 17 public: | 17 public: |
| 18 // Removes any recorded counts for urls which match |filter| under |profile|. | 18 // Removes any recorded counts for urls which match |filter| under |profile|. |
| 19 static void RemoveCountsByUrl(Profile* profile, | 19 static void RemoveCountsByUrl(Profile* profile, |
| 20 base::Callback<bool(const GURL& url)> filter); | 20 base::Callback<bool(const GURL& url)> filter); |
| 21 | 21 |
| 22 // Returns the current number of dismisses recorded for |permission| | 22 // Returns the current number of dismisses recorded for |permission| type at |
| 23 // type at |url|. | 23 // |url|. |
| 24 static int GetDismissCount(const GURL& url, | 24 static int GetDismissCount(const GURL& url, |
| 25 content::PermissionType permission, | 25 content::PermissionType permission, |
| 26 Profile* profile); | 26 Profile* profile); |
| 27 | 27 |
| 28 // Returns the current number of ignores recorded for |permission| | 28 // Returns the current number of ignores recorded for |permission| |
| 29 // type at |url|. | 29 // type at |url|. |
| 30 static int GetIgnoreCount(const GURL& url, | 30 static int GetIgnoreCount(const GURL& url, |
| 31 content::PermissionType permission, | 31 content::PermissionType permission, |
| 32 Profile* profile); | 32 Profile* profile); |
| 33 | 33 |
| 34 explicit PermissionDecisionAutoBlocker(Profile* profile); | 34 // Records that a dismissal of a prompt for |permission| was made. |
| 35 static int RecordDismiss(const GURL& url, | |
| 36 content::PermissionType permission, | |
| 37 Profile* profile); | |
| 35 | 38 |
| 36 // Records that an ignore of a prompt for |permission| was made. | 39 // Records that an ignore of a prompt for |permission| was made. |
| 37 int RecordIgnore(const GURL& url, content::PermissionType permission); | 40 static int RecordIgnore(const GURL& url, |
| 41 content::PermissionType permission, | |
| 42 Profile* profile); | |
| 38 | 43 |
| 39 // Records that a dismissal of a prompt for |permission| was made, and returns | 44 // Records that a dismissal of a prompt for |permission| was made, and returns |
| 40 // true if this dismissal should be considered a block. False otherwise. | 45 // true if this dismissal should be considered a block. False otherwise. |
| 41 bool ShouldChangeDismissalToBlock(const GURL& url, | 46 static bool ShouldChangeDismissalToBlock(const GURL& url, |
| 42 content::PermissionType permission); | 47 content::PermissionType permission, |
| 48 Profile* profile); | |
| 49 | |
| 50 // Updates the number of prompts before blocking. | |
|
raymes
2016/10/05 05:02:32
nit: Updates the threshold at which to start block
dominickn
2016/10/05 05:55:30
Done.
| |
| 51 static void UpdateFromVariations(); | |
| 43 | 52 |
| 44 private: | 53 private: |
|
raymes
2016/10/05 05:02:32
nit: DISALLOW_IMPLICIT_CONSTRUCTORS
dominickn
2016/10/05 05:55:30
Done.
| |
| 45 friend class PermissionContextBaseTests; | 54 friend class PermissionContextBaseTests; |
| 46 | 55 |
| 47 // Keys used for storing count data in a website setting. | 56 // Keys used for storing count data in a website setting. |
| 48 static const char kPromptDismissCountKey[]; | 57 static const char kPromptDismissCountKey[]; |
| 49 static const char kPromptIgnoreCountKey[]; | 58 static const char kPromptIgnoreCountKey[]; |
| 50 | |
| 51 // Updates |prompt_dismissals_before_block_|. | |
| 52 void UpdateFromVariations(); | |
| 53 | |
| 54 Profile *profile_; | |
| 55 int prompt_dismissals_before_block_; | |
| 56 }; | 59 }; |
| 57 | 60 |
| 58 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_DECISION_AUTO_BLOCKER_H_ | 61 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_DECISION_AUTO_BLOCKER_H_ |
| OLD | NEW |