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

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

Issue 2675483002: Replace PermissionType in chrome/ with ContentSettingsType (Closed)
Patch Set: ready 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"
11 #include "base/memory/singleton.h" 11 #include "base/memory/singleton.h"
12 #include "base/time/default_clock.h" 12 #include "base/time/default_clock.h"
13 #include "components/content_settings/core/common/content_settings_types.h"
13 #include "components/keyed_service/content/browser_context_keyed_service_factory .h" 14 #include "components/keyed_service/content/browser_context_keyed_service_factory .h"
14 #include "components/keyed_service/core/keyed_service.h" 15 #include "components/keyed_service/core/keyed_service.h"
15 #include "content/public/browser/permission_type.h"
16 #include "url/gurl.h" 16 #include "url/gurl.h"
17 17
18 class GURL; 18 class GURL;
19 class Profile; 19 class Profile;
20 20
21 namespace content { 21 namespace content {
22 class WebContents; 22 class WebContents;
23 } 23 }
24 24
25 namespace safe_browsing { 25 namespace safe_browsing {
(...skipping 29 matching lines...) Expand all
55 content::BrowserContext* context) const override; 55 content::BrowserContext* context) const override;
56 }; 56 };
57 57
58 static PermissionDecisionAutoBlocker* GetForProfile(Profile* profile); 58 static PermissionDecisionAutoBlocker* GetForProfile(Profile* profile);
59 59
60 // Removes any recorded counts for urls which match |filter|. 60 // Removes any recorded counts for urls which match |filter|.
61 void RemoveCountsByUrl(base::Callback<bool(const GURL& url)> filter); 61 void RemoveCountsByUrl(base::Callback<bool(const GURL& url)> filter);
62 62
63 // Returns the current number of dismisses recorded for |permission| type at 63 // Returns the current number of dismisses recorded for |permission| type at
64 // |url|. 64 // |url|.
65 int GetDismissCount(const GURL& url, content::PermissionType permission); 65 int GetDismissCount(const GURL& url, ContentSettingsType permission);
66 66
67 // Returns the current number of ignores recorded for |permission| 67 // Returns the current number of ignores recorded for |permission|
68 // type at |url|. 68 // type at |url|.
69 int GetIgnoreCount(const GURL& url, content::PermissionType permission); 69 int GetIgnoreCount(const GURL& url, ContentSettingsType permission);
70 70
71 // Records that a dismissal of a prompt for |permission| was made. If the 71 // Records that a dismissal of a prompt for |permission| was made. If the
72 // total number of dismissals exceeds a threshhold and 72 // total number of dismissals exceeds a threshhold and
73 // features::kBlockPromptsIfDismissedOften is enabled it will place |url| 73 // features::kBlockPromptsIfDismissedOften is enabled it will place |url|
74 // under embargo for |permission|. 74 // under embargo for |permission|.
75 bool RecordDismissAndEmbargo(const GURL& url, 75 bool RecordDismissAndEmbargo(const GURL& url, ContentSettingsType permission);
76 content::PermissionType permission);
77 76
78 // Records that an ignore of a prompt for |permission| was made. 77 // Records that an ignore of a prompt for |permission| was made.
79 int RecordIgnore(const GURL& url, content::PermissionType permission); 78 int RecordIgnore(const GURL& url, ContentSettingsType permission);
80 79
81 // Updates the threshold to start blocking prompts from the field trial. 80 // Updates the threshold to start blocking prompts from the field trial.
82 static void UpdateFromVariations(); 81 static void UpdateFromVariations();
83 82
84 // Checks if |request_origin| is under embargo for |permission|. Internally, 83 // Checks if |request_origin| is under embargo for |permission|. Internally,
85 // this will make a call to IsUnderEmbargo to check the content setting first, 84 // this will make a call to IsUnderEmbargo to check the content setting first,
86 // but may also make a call to Safe Browsing to check the API blacklist, which 85 // but may also make a call to Safe Browsing to check the API blacklist, which
87 // is performed asynchronously. 86 // is performed asynchronously.
88 void UpdateEmbargoedStatus(content::PermissionType permission, 87 void UpdateEmbargoedStatus(ContentSettingsType permission,
89 const GURL& request_origin, 88 const GURL& request_origin,
90 content::WebContents* web_contents, 89 content::WebContents* web_contents,
91 base::Callback<void(bool)> callback); 90 base::Callback<void(bool)> callback);
92 91
93 // Checks the status of the content setting to determine if |request_origin| 92 // Checks the status of the content setting to determine if |request_origin|
94 // is under embargo for |permission|. This checks both embargo for Permissions 93 // is under embargo for |permission|. This checks both embargo for Permissions
95 // Blacklisting and repeated dismissals. 94 // Blacklisting and repeated dismissals.
96 bool IsUnderEmbargo(content::PermissionType permission, 95 bool IsUnderEmbargo(ContentSettingsType permission,
97 const GURL& request_origin); 96 const GURL& request_origin);
98 97
99 private: 98 private:
100 friend class PermissionContextBaseTests; 99 friend class PermissionContextBaseTests;
101 friend class PermissionDecisionAutoBlockerUnitTest; 100 friend class PermissionDecisionAutoBlockerUnitTest;
102 101
103 explicit PermissionDecisionAutoBlocker(Profile* profile); 102 explicit PermissionDecisionAutoBlocker(Profile* profile);
104 ~PermissionDecisionAutoBlocker() override; 103 ~PermissionDecisionAutoBlocker() override;
105 104
106 // 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
107 // then |request_origin| will be placed under embargo for that |permission|. 106 // then |request_origin| will be placed under embargo for that |permission|.
108 void CheckSafeBrowsingResult(content::PermissionType permission, 107 void CheckSafeBrowsingResult(ContentSettingsType permission,
109 const GURL& request_origin, 108 const GURL& request_origin,
110 base::Callback<void(bool)> callback, 109 base::Callback<void(bool)> callback,
111 bool should_be_embargoed); 110 bool should_be_embargoed);
112 111
113 void PlaceUnderEmbargo(content::PermissionType permission, 112 void PlaceUnderEmbargo(ContentSettingsType permission,
114 const GURL& request_origin, 113 const GURL& request_origin,
115 const char* key); 114 const char* key);
116 115
117 void SetSafeBrowsingDatabaseManagerAndTimeoutForTesting( 116 void SetSafeBrowsingDatabaseManagerAndTimeoutForTesting(
118 scoped_refptr<safe_browsing::SafeBrowsingDatabaseManager> db_manager, 117 scoped_refptr<safe_browsing::SafeBrowsingDatabaseManager> db_manager,
119 int timeout); 118 int timeout);
120 119
121 void SetClockForTesting(std::unique_ptr<base::Clock> clock); 120 void SetClockForTesting(std::unique_ptr<base::Clock> clock);
122 121
123 // Keys used for storing count data in a website setting. 122 // Keys used for storing count data in a website setting.
124 static const char kPromptDismissCountKey[]; 123 static const char kPromptDismissCountKey[];
125 static const char kPromptIgnoreCountKey[]; 124 static const char kPromptIgnoreCountKey[];
126 static const char kPermissionDismissalEmbargoKey[]; 125 static const char kPermissionDismissalEmbargoKey[];
127 static const char kPermissionBlacklistEmbargoKey[]; 126 static const char kPermissionBlacklistEmbargoKey[];
128 127
129 Profile* profile_; 128 Profile* profile_;
130 scoped_refptr<safe_browsing::SafeBrowsingDatabaseManager> db_manager_; 129 scoped_refptr<safe_browsing::SafeBrowsingDatabaseManager> db_manager_;
131 130
132 // Timeout in ms. 131 // Timeout in ms.
133 int safe_browsing_timeout_; 132 int safe_browsing_timeout_;
134 133
135 std::unique_ptr<base::Clock> clock_; 134 std::unique_ptr<base::Clock> clock_;
136 135
137 DISALLOW_IMPLICIT_CONSTRUCTORS(PermissionDecisionAutoBlocker); 136 DISALLOW_IMPLICIT_CONSTRUCTORS(PermissionDecisionAutoBlocker);
138 }; 137 };
139 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_DECISION_AUTO_BLOCKER_H_ 138 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_DECISION_AUTO_BLOCKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698