Index: components/subresource_filter/content/browser/subresource_filter_safe_browsing_activation_throttle.h |
diff --git a/components/subresource_filter/content/browser/subresource_filter_safe_browsing_activation_throttle.h b/components/subresource_filter/content/browser/subresource_filter_safe_browsing_activation_throttle.h |
index 082076bada73025e92da54388e49941aa0862fcb..7f0a6a3cbb2078aeca899a9e8d14a59238c7c31f 100644 |
--- a/components/subresource_filter/content/browser/subresource_filter_safe_browsing_activation_throttle.h |
+++ b/components/subresource_filter/content/browser/subresource_filter_safe_browsing_activation_throttle.h |
@@ -5,16 +5,26 @@ |
#ifndef COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_SUBRESOURCE_FILTER_SAFE_BROWSING_ACTIVATION_THROTTLE_H_ |
#define COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_SUBRESOURCE_FILTER_SAFE_BROWSING_ACTIVATION_THROTTLE_H_ |
+#include <memory> |
+ |
#include "base/macros.h" |
#include "base/memory/ref_counted.h" |
#include "base/memory/weak_ptr.h" |
#include "base/single_thread_task_runner.h" |
+#include "base/time/time.h" |
#include "components/safe_browsing_db/database_manager.h" |
#include "content/public/browser/navigation_throttle.h" |
-#include "url/gurl.h" |
+ |
+class GURL; |
+ |
+namespace base { |
+class Timer; |
+} // namespace base |
namespace subresource_filter { |
+class SubresourceFilterSafeBrowsingClient; |
+ |
// Navigation throttle responsible for activating subresource filtering on page |
// loads that match the SUBRESOURCE_FILTER Safe Browsing list. |
class SubresourceFilterSafeBrowsingActivationThrottle |
@@ -24,24 +34,47 @@ class SubresourceFilterSafeBrowsingActivationThrottle |
public: |
SubresourceFilterSafeBrowsingActivationThrottle( |
content::NavigationHandle* handle, |
+ std::unique_ptr<base::Timer> timer, |
scoped_refptr<safe_browsing::SafeBrowsingDatabaseManager> |
database_manager); |
~SubresourceFilterSafeBrowsingActivationThrottle() override; |
// content::NavigationThrottle: |
+ content::NavigationThrottle::ThrottleCheckResult WillStartRequest() override; |
+ content::NavigationThrottle::ThrottleCheckResult WillRedirectRequest() |
+ override; |
content::NavigationThrottle::ThrottleCheckResult WillProcessResponse() |
override; |
void OnCheckUrlResultOnUI(const GURL& url, |
+ int request_id, |
safe_browsing::SBThreatType threat_type, |
safe_browsing::ThreatPatternType pattern_type); |
private: |
- class SBDatabaseClient; |
+ void CheckUrl(); |
+ void NotifyResult(); |
+ scoped_refptr<safe_browsing::SafeBrowsingDatabaseManager> database_manager_; |
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; |
- std::unique_ptr<SBDatabaseClient, base::OnTaskRunnerDeleter> database_client_; |
+ |
+ int current_request_id_ = 0; |
+ int last_received_request_id_ = 0; |
+ |
+ // Cached check results to be forwarded in WillProessResponse. |
+ safe_browsing::SBThreatType threat_type_ = |
+ safe_browsing::SBThreatType::SB_THREAT_TYPE_SAFE; |
+ safe_browsing::ThreatPatternType pattern_type_ = |
+ safe_browsing::ThreatPatternType::NONE; |
+ |
+ std::unique_ptr<SubresourceFilterSafeBrowsingClient, |
+ base::OnTaskRunnerDeleter> |
+ database_client_; |
+ |
+ // Set to TimeTicks::Now() when the navigation is deferred in |
+ // WillProcessResponse. If deferral was not necessary, will remain null. |
+ base::TimeTicks defer_time_; |
DISALLOW_COPY_AND_ASSIGN(SubresourceFilterSafeBrowsingActivationThrottle); |
}; |