Index: chrome/browser/permissions/permission_decision_auto_blocker.h |
diff --git a/chrome/browser/permissions/permission_decision_auto_blocker.h b/chrome/browser/permissions/permission_decision_auto_blocker.h |
index 89ecfc7f77e2b920d393b9493026a214277a7408..844a15d1502f784913baef9f976c1ab110cf4e54 100644 |
--- a/chrome/browser/permissions/permission_decision_auto_blocker.h |
+++ b/chrome/browser/permissions/permission_decision_auto_blocker.h |
@@ -5,14 +5,30 @@ |
#ifndef CHROME_BROWSER_PERMISSIONS_PERMISSION_DECISION_AUTO_BLOCKER_H_ |
#define CHROME_BROWSER_PERMISSIONS_PERMISSION_DECISION_AUTO_BLOCKER_H_ |
+#include "base/callback.h" |
#include "base/callback_forward.h" |
dominickn
2017/01/11 07:52:13
Remove callback_forward.h
meredithl
2017/01/11 23:22:28
Done.
|
#include "base/macros.h" |
+#include "base/memory/ref_counted.h" |
#include "content/public/browser/permission_type.h" |
#include "url/gurl.h" |
class GURL; |
class Profile; |
+namespace content { |
+class WebContents; |
+} |
+ |
+namespace safe_browsing { |
+class SafeBrowsingDatabaseManager; |
+} |
+ |
+namespace base { |
+class Time; |
+} |
+ |
+class HostContentSettingsMap; |
+ |
dominickn
2017/01/11 07:52:13
Add a class comment here explaining what embargo i
meredithl
2017/01/11 23:22:28
Yep! I've also left a TODO explaining that this wi
|
class PermissionDecisionAutoBlocker { |
public: |
// Removes any recorded counts for urls which match |filter| under |profile|. |
@@ -50,12 +66,51 @@ class PermissionDecisionAutoBlocker { |
// Updates the threshold to start blocking prompts from the field trial. |
static void UpdateFromVariations(); |
+ // Checks if the |request_origin| is under embargo for the requested |
+ // |permission|. Internally, this will make a call to IsUnderEmbargo to check |
+ // the content setting first, but may also make a call to Safe Browsing to |
+ // check if the |request_origin| is blacklisted for |permission|, which is |
+ // performed asynchronously. |
+ static void ShouldAutomaticallyBlock( |
+ scoped_refptr<safe_browsing::SafeBrowsingDatabaseManager> db_manager, |
+ content::PermissionType permission, |
+ const GURL& request_origin, |
+ content::WebContents* web_contents, |
+ int timeout, |
+ Profile* profile, |
+ base::Time current_time, |
+ base::Callback<void(bool)> callback); |
+ |
+ // Checks the status of the content setting to determine if |request_origin| |
+ // is under embargo for the |permission|. This check is done synchronously. |
+ static bool IsUnderEmbargo(content::PermissionType permission, |
+ Profile* profile, |
+ const GURL& request_origin, |
+ base::Time current_time); |
+ |
private: |
friend class PermissionContextBaseTests; |
+ friend class PermissionDecisionAutoBlockerUnitTest; |
+ |
+ // Get the result of the Safe Browsing check, if |should_be_embargoed| then |
dominickn
2017/01/11 07:52:13
"if |should_be_embargoed| is true then".
meredithl
2017/01/11 23:22:28
Done.
|
+ // |request_origin| will be placed under embargo. |
+ static void CheckSafeBrowsingResult(content::PermissionType permission, |
+ Profile* profile, |
+ const GURL& request_origin, |
+ base::Callback<void(bool)> callback, |
+ bool should_be_embargoed); |
+ |
+ // Sets the embargo status of the |request_origin| inside the |permission| |
+ // dictionary. |
+ static void PlaceUnderEmbargo(content::PermissionType permission, |
+ const GURL& request_origin, |
+ HostContentSettingsMap* map, |
+ base::Time current_time); |
// Keys used for storing count data in a website setting. |
static const char kPromptDismissCountKey[]; |
static const char kPromptIgnoreCountKey[]; |
+ static const char kPermissionOriginEmbargoKey[]; |
DISALLOW_IMPLICIT_CONSTRUCTORS(PermissionDecisionAutoBlocker); |
}; |