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

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

Issue 2701343002: Implement permission embargo suppression metrics. (Closed)
Patch Set: Rebase Created 3 years, 9 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 "chrome/browser/permissions/permission_util.h"
13 #include "components/content_settings/core/common/content_settings_types.h" 14 #include "components/content_settings/core/common/content_settings_types.h"
14 #include "components/keyed_service/content/browser_context_keyed_service_factory .h" 15 #include "components/keyed_service/content/browser_context_keyed_service_factory .h"
15 #include "components/keyed_service/core/keyed_service.h" 16 #include "components/keyed_service/core/keyed_service.h"
16 #include "url/gurl.h" 17 #include "url/gurl.h"
17 18
18 class GURL; 19 class GURL;
19 class Profile; 20 class Profile;
20 21
21 namespace content { 22 namespace content {
22 class WebContents; 23 class WebContents;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 // features::kBlockPromptsIfDismissedOften is enabled it will place |url| 74 // features::kBlockPromptsIfDismissedOften is enabled it will place |url|
74 // under embargo for |permission|. 75 // under embargo for |permission|.
75 bool RecordDismissAndEmbargo(const GURL& url, ContentSettingsType permission); 76 bool RecordDismissAndEmbargo(const GURL& url, ContentSettingsType permission);
76 77
77 // Records that an ignore of a prompt for |permission| was made. 78 // Records that an ignore of a prompt for |permission| was made.
78 int RecordIgnore(const GURL& url, ContentSettingsType permission); 79 int RecordIgnore(const GURL& url, ContentSettingsType permission);
79 80
80 // Updates the threshold to start blocking prompts from the field trial. 81 // Updates the threshold to start blocking prompts from the field trial.
81 static void UpdateFromVariations(); 82 static void UpdateFromVariations();
82 83
83 // Checks if |request_origin| is under embargo for |permission|. Internally, 84 // Updates whether |request_origin| should be under embargo for |permission|.
84 // this will make a call to IsUnderEmbargo to check the content setting first, 85 // Makes an asynchronous call to Safe Browsing to check the API blacklist.
85 // but may also make a call to Safe Browsing to check the API blacklist, which
86 // is performed asynchronously.
87 void UpdateEmbargoedStatus(ContentSettingsType permission, 86 void UpdateEmbargoedStatus(ContentSettingsType permission,
88 const GURL& request_origin, 87 const GURL& request_origin,
89 content::WebContents* web_contents, 88 content::WebContents* web_contents,
90 base::Callback<void(bool)> callback); 89 base::Callback<void(bool)> callback);
91 90
92 // Checks the status of the content setting to determine if |request_origin| 91 // Checks the status of the content setting to determine if |request_origin|
93 // is under embargo for |permission|. This checks both embargo for Permissions 92 // is under embargo for |permission|. This checks both embargo for Permissions
94 // Blacklisting and repeated dismissals. 93 // Blacklisting and repeated dismissals.
95 bool IsUnderEmbargo(ContentSettingsType permission, 94 PermissionResult GetEmbargoResult(ContentSettingsType permission,
96 const GURL& request_origin); 95 const GURL& request_origin);
97 96
98 private: 97 private:
99 friend class PermissionContextBaseTests; 98 friend class PermissionContextBaseTests;
100 friend class PermissionDecisionAutoBlockerUnitTest; 99 friend class PermissionDecisionAutoBlockerUnitTest;
101 100
102 explicit PermissionDecisionAutoBlocker(Profile* profile); 101 explicit PermissionDecisionAutoBlocker(Profile* profile);
103 ~PermissionDecisionAutoBlocker() override; 102 ~PermissionDecisionAutoBlocker() override;
104 103
105 // Get the result of the Safe Browsing check, if |should_be_embargoed| is true 104 // Get the result of the Safe Browsing check, if |should_be_embargoed| is true
106 // then |request_origin| will be placed under embargo for that |permission|. 105 // then |request_origin| will be placed under embargo for that |permission|.
(...skipping 22 matching lines...) Expand all
129 scoped_refptr<safe_browsing::SafeBrowsingDatabaseManager> db_manager_; 128 scoped_refptr<safe_browsing::SafeBrowsingDatabaseManager> db_manager_;
130 129
131 // Timeout in ms. 130 // Timeout in ms.
132 int safe_browsing_timeout_; 131 int safe_browsing_timeout_;
133 132
134 std::unique_ptr<base::Clock> clock_; 133 std::unique_ptr<base::Clock> clock_;
135 134
136 DISALLOW_IMPLICIT_CONSTRUCTORS(PermissionDecisionAutoBlocker); 135 DISALLOW_IMPLICIT_CONSTRUCTORS(PermissionDecisionAutoBlocker);
137 }; 136 };
138 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_DECISION_AUTO_BLOCKER_H_ 137 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_DECISION_AUTO_BLOCKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698