| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_PERMISSIONS_PERMISSION_DECISION_AUTO_BLOCKER_H_ |
| 6 #define CHROME_BROWSER_PERMISSIONS_PERMISSION_DECISION_AUTO_BLOCKER_H_ |
| 7 |
| 8 #include "base/callback_forward.h" |
| 9 #include "base/macros.h" |
| 10 #include "content/public/browser/permission_type.h" |
| 11 #include "url/gurl.h" |
| 12 |
| 13 class GURL; |
| 14 class Profile; |
| 15 |
| 16 class PermissionDecisionAutoBlocker { |
| 17 public: |
| 18 // Removes any recorded counts for urls which match |filter| under |profile|. |
| 19 static void RemoveCountsByUrl(Profile* profile, |
| 20 base::Callback<bool(const GURL& url)> filter); |
| 21 |
| 22 explicit PermissionDecisionAutoBlocker(Profile* profile); |
| 23 |
| 24 // Records that an ignore of a prompt for |permission| was made. |
| 25 int RecordIgnore(const GURL& url, content::PermissionType permission); |
| 26 |
| 27 // Records that a dismissal of a prompt for |permission| was made, and returns |
| 28 // true if this dismissal should be considered a block. False otherwise. |
| 29 bool ShouldChangeDismissalToBlock(const GURL& url, |
| 30 content::PermissionType permission); |
| 31 |
| 32 private: |
| 33 friend class PermissionContextBaseTests; |
| 34 friend class PermissionDecisionAutoBlockerUnitTest; |
| 35 |
| 36 // Keys used for storing count data in a website setting. |
| 37 static const char kPromptDismissCountKey[]; |
| 38 static const char kPromptIgnoreCountKey[]; |
| 39 |
| 40 // Returns the current number of actions recorded under |key| for |permission| |
| 41 // type at |url|. |
| 42 int GetActionCountForTest(const GURL& url, |
| 43 content::PermissionType permission, |
| 44 const char* key); |
| 45 |
| 46 // Records that the user performed an action for a prompt of type |permission| |
| 47 // on |url| to a website setting keyed by |key|. Returns the total number of |
| 48 // |key| actions which have been performed for |url|. |
| 49 int RecordActionInWebsiteSettings(const GURL& url, |
| 50 content::PermissionType permission, |
| 51 const char* key); |
| 52 |
| 53 // Updates |prompt_dismissals_before_block_|. |
| 54 void UpdateFromVariations(); |
| 55 |
| 56 Profile *profile_; |
| 57 int prompt_dismissals_before_block_; |
| 58 }; |
| 59 |
| 60 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_DECISION_AUTO_BLOCKER_H_ |
| OLD | NEW |