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..09657ead75b93210b718ae9ea88f2fc6a6aacd2d 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 |
@@ -1,20 +1,27 @@ |
-// Copyright (c) 2017 The Chromium Authors. All rights reserved. |
+// Copyright 2017 The Chromium Authors. All rights reserved. |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
#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 <vector> |
+ |
#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 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 +31,47 @@ class SubresourceFilterSafeBrowsingActivationThrottle |
public: |
SubresourceFilterSafeBrowsingActivationThrottle( |
content::NavigationHandle* handle, |
+ scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, |
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, |
+ size_t request_id, |
safe_browsing::SBThreatType threat_type, |
safe_browsing::ThreatPatternType pattern_type); |
private: |
- class SBDatabaseClient; |
+ void CheckUrl(); |
+ void NotifyResult(); |
+ struct CheckResult { |
+ safe_browsing::SBThreatType threat_type = |
+ safe_browsing::SBThreatType::SB_THREAT_TYPE_SAFE; |
+ safe_browsing::ThreatPatternType pattern_type = |
+ safe_browsing::ThreatPatternType::NONE; |
+ bool finished = false; |
+ }; |
+ std::vector<CheckResult> check_results_; |
+ |
+ scoped_refptr<safe_browsing::SafeBrowsingDatabaseManager> database_manager_; |
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; |
- std::unique_ptr<SBDatabaseClient, base::OnTaskRunnerDeleter> database_client_; |
+ |
+ 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); |
}; |