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

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

Issue 2709213004: Make the PermissionDecisionAutoBlocker API consistent. (Closed)
Patch Set: Rebase Created 3 years, 10 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 // BrowserContextKeyedServiceFactory 51 // BrowserContextKeyedServiceFactory
52 KeyedService* BuildServiceInstanceFor( 52 KeyedService* BuildServiceInstanceFor(
53 content::BrowserContext* context) const override; 53 content::BrowserContext* context) const override;
54 54
55 content::BrowserContext* GetBrowserContextToUse( 55 content::BrowserContext* GetBrowserContextToUse(
56 content::BrowserContext* context) const override; 56 content::BrowserContext* context) const override;
57 }; 57 };
58 58
59 static PermissionDecisionAutoBlocker* GetForProfile(Profile* profile); 59 static PermissionDecisionAutoBlocker* GetForProfile(Profile* profile);
60 60
61 // Removes any recorded counts for urls which match |filter|. 61 // Updates the threshold to start blocking prompts from the field trial.
62 void RemoveCountsByUrl(base::Callback<bool(const GURL& url)> filter); 62 static void UpdateFromVariations();
63
64 // Makes an asynchronous call to Safe Browsing to check the API blacklist.
65 // Places the (|request_origin|, |permission|) pair under embargo if they are
66 // on the blacklist.
67 void CheckSafeBrowsingBlacklist(content::WebContents* web_contents,
68 const GURL& request_origin,
69 ContentSettingsType permission,
70 base::Callback<void(bool)> callback);
71
72 // Checks the status of the content setting to determine if |request_origin|
73 // is under embargo for |permission|. This checks both embargo for Permissions
74 // Blacklisting and repeated dismissals.
75 PermissionResult GetEmbargoResult(const GURL& request_origin,
76 ContentSettingsType permission);
63 77
64 // Returns the current number of dismisses recorded for |permission| type at 78 // Returns the current number of dismisses recorded for |permission| type at
65 // |url|. 79 // |url|.
66 int GetDismissCount(const GURL& url, ContentSettingsType permission); 80 int GetDismissCount(const GURL& url, ContentSettingsType permission);
67 81
68 // Returns the current number of ignores recorded for |permission| 82 // Returns the current number of ignores recorded for |permission|
69 // type at |url|. 83 // type at |url|.
70 int GetIgnoreCount(const GURL& url, ContentSettingsType permission); 84 int GetIgnoreCount(const GURL& url, ContentSettingsType permission);
71 85
72 // 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
73 // total number of dismissals exceeds a threshhold and 87 // total number of dismissals exceeds a threshhold and
74 // features::kBlockPromptsIfDismissedOften is enabled it will place |url| 88 // features::kBlockPromptsIfDismissedOften is enabled it will place |url|
75 // under embargo for |permission|. 89 // under embargo for |permission|.
76 bool RecordDismissAndEmbargo(const GURL& url, ContentSettingsType permission); 90 bool RecordDismissAndEmbargo(const GURL& url, ContentSettingsType permission);
77 91
78 // Records that an ignore of a prompt for |permission| was made. 92 // Records that an ignore of a prompt for |permission| was made.
79 int RecordIgnore(const GURL& url, ContentSettingsType permission); 93 int RecordIgnore(const GURL& url, ContentSettingsType permission);
80 94
81 // Updates the threshold to start blocking prompts from the field trial. 95 // Removes any recorded counts for urls which match |filter|.
82 static void UpdateFromVariations(); 96 void RemoveCountsByUrl(base::Callback<bool(const GURL& url)> filter);
83
84 // Updates whether |request_origin| should be under embargo for |permission|.
85 // Makes an asynchronous call to Safe Browsing to check the API blacklist.
86 void UpdateEmbargoedStatus(ContentSettingsType permission,
87 const GURL& request_origin,
88 content::WebContents* web_contents,
89 base::Callback<void(bool)> callback);
90
91 // Checks the status of the content setting to determine if |request_origin|
92 // is under embargo for |permission|. This checks both embargo for Permissions
93 // Blacklisting and repeated dismissals.
94 PermissionResult GetEmbargoResult(ContentSettingsType permission,
95 const GURL& request_origin);
96 97
97 private: 98 private:
98 friend class PermissionContextBaseTests; 99 friend class PermissionContextBaseTests;
99 friend class PermissionDecisionAutoBlockerUnitTest; 100 friend class PermissionDecisionAutoBlockerUnitTest;
100 101
101 explicit PermissionDecisionAutoBlocker(Profile* profile); 102 explicit PermissionDecisionAutoBlocker(Profile* profile);
102 ~PermissionDecisionAutoBlocker() override; 103 ~PermissionDecisionAutoBlocker() override;
103 104
104 // Get the result of the Safe Browsing check, if |should_be_embargoed| is true 105 // Get the result of the Safe Browsing check, if |should_be_embargoed| is true
105 // then |request_origin| will be placed under embargo for that |permission|. 106 // then |request_origin| will be placed under embargo for that |permission|.
106 void CheckSafeBrowsingResult(ContentSettingsType permission, 107 void CheckSafeBrowsingResult(const GURL& request_origin,
107 const GURL& request_origin, 108 ContentSettingsType permission,
108 base::Callback<void(bool)> callback, 109 base::Callback<void(bool)> callback,
109 bool should_be_embargoed); 110 bool should_be_embargoed);
110 111
111 void PlaceUnderEmbargo(ContentSettingsType permission, 112 void PlaceUnderEmbargo(const GURL& request_origin,
112 const GURL& request_origin, 113 ContentSettingsType permission,
113 const char* key); 114 const char* key);
114 115
115 void SetSafeBrowsingDatabaseManagerAndTimeoutForTesting( 116 void SetSafeBrowsingDatabaseManagerAndTimeoutForTesting(
116 scoped_refptr<safe_browsing::SafeBrowsingDatabaseManager> db_manager, 117 scoped_refptr<safe_browsing::SafeBrowsingDatabaseManager> db_manager,
117 int timeout); 118 int timeout);
118 119
119 void SetClockForTesting(std::unique_ptr<base::Clock> clock); 120 void SetClockForTesting(std::unique_ptr<base::Clock> clock);
120 121
121 // Keys used for storing count data in a website setting. 122 // Keys used for storing count data in a website setting.
122 static const char kPromptDismissCountKey[]; 123 static const char kPromptDismissCountKey[];
123 static const char kPromptIgnoreCountKey[]; 124 static const char kPromptIgnoreCountKey[];
124 static const char kPermissionDismissalEmbargoKey[]; 125 static const char kPermissionDismissalEmbargoKey[];
125 static const char kPermissionBlacklistEmbargoKey[]; 126 static const char kPermissionBlacklistEmbargoKey[];
126 127
127 Profile* profile_; 128 Profile* profile_;
128 scoped_refptr<safe_browsing::SafeBrowsingDatabaseManager> db_manager_; 129 scoped_refptr<safe_browsing::SafeBrowsingDatabaseManager> db_manager_;
129 130
130 // Timeout in ms. 131 // Timeout in ms.
131 int safe_browsing_timeout_; 132 int safe_browsing_timeout_;
132 133
133 std::unique_ptr<base::Clock> clock_; 134 std::unique_ptr<base::Clock> clock_;
134 135
135 DISALLOW_IMPLICIT_CONSTRUCTORS(PermissionDecisionAutoBlocker); 136 DISALLOW_IMPLICIT_CONSTRUCTORS(PermissionDecisionAutoBlocker);
136 }; 137 };
137 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_DECISION_AUTO_BLOCKER_H_ 138 #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