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

Side by Side Diff: components/subresource_filter/content/browser/subresource_filter_safe_browsing_activation_throttle.h

Issue 2834543003: [subresource_filter] SB throttle can send multiple speculative requests. (Closed)
Patch Set: Remove UAF Created 3 years, 8 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 (c) 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_SUBRESOURCE_FILTER_SAFE_BR OWSING_ACTIVATION_THROTTLE_H_ 5 #ifndef COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_SUBRESOURCE_FILTER_SAFE_BR OWSING_ACTIVATION_THROTTLE_H_
6 #define COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_SUBRESOURCE_FILTER_SAFE_BR OWSING_ACTIVATION_THROTTLE_H_ 6 #define COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_SUBRESOURCE_FILTER_SAFE_BR OWSING_ACTIVATION_THROTTLE_H_
7 7
8 #include <memory>
9
8 #include "base/macros.h" 10 #include "base/macros.h"
9 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
10 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
11 #include "base/single_thread_task_runner.h" 13 #include "base/single_thread_task_runner.h"
14 #include "base/time/time.h"
12 #include "components/safe_browsing_db/database_manager.h" 15 #include "components/safe_browsing_db/database_manager.h"
13 #include "content/public/browser/navigation_throttle.h" 16 #include "content/public/browser/navigation_throttle.h"
14 #include "url/gurl.h" 17
18 class GURL;
19
20 namespace base {
21 class Timer;
22 } // namespace base
15 23
16 namespace subresource_filter { 24 namespace subresource_filter {
17 25
26 class SubresourceFilterSafeBrowsingClient;
27
18 // Navigation throttle responsible for activating subresource filtering on page 28 // Navigation throttle responsible for activating subresource filtering on page
19 // loads that match the SUBRESOURCE_FILTER Safe Browsing list. 29 // loads that match the SUBRESOURCE_FILTER Safe Browsing list.
20 class SubresourceFilterSafeBrowsingActivationThrottle 30 class SubresourceFilterSafeBrowsingActivationThrottle
21 : public content::NavigationThrottle, 31 : public content::NavigationThrottle,
22 public base::SupportsWeakPtr< 32 public base::SupportsWeakPtr<
23 SubresourceFilterSafeBrowsingActivationThrottle> { 33 SubresourceFilterSafeBrowsingActivationThrottle> {
24 public: 34 public:
25 SubresourceFilterSafeBrowsingActivationThrottle( 35 SubresourceFilterSafeBrowsingActivationThrottle(
26 content::NavigationHandle* handle, 36 content::NavigationHandle* handle,
37 std::unique_ptr<base::Timer> timer,
27 scoped_refptr<safe_browsing::SafeBrowsingDatabaseManager> 38 scoped_refptr<safe_browsing::SafeBrowsingDatabaseManager>
28 database_manager); 39 database_manager);
29 40
30 ~SubresourceFilterSafeBrowsingActivationThrottle() override; 41 ~SubresourceFilterSafeBrowsingActivationThrottle() override;
31 42
32 // content::NavigationThrottle: 43 // content::NavigationThrottle:
44 content::NavigationThrottle::ThrottleCheckResult WillStartRequest() override;
45 content::NavigationThrottle::ThrottleCheckResult WillRedirectRequest()
46 override;
33 content::NavigationThrottle::ThrottleCheckResult WillProcessResponse() 47 content::NavigationThrottle::ThrottleCheckResult WillProcessResponse()
34 override; 48 override;
35 49
36 void OnCheckUrlResultOnUI(const GURL& url, 50 void OnCheckUrlResultOnUI(const GURL& url,
51 int request_id,
37 safe_browsing::SBThreatType threat_type, 52 safe_browsing::SBThreatType threat_type,
38 safe_browsing::ThreatPatternType pattern_type); 53 safe_browsing::ThreatPatternType pattern_type);
39 54
40 private: 55 private:
41 class SBDatabaseClient; 56 void CheckUrl();
57 void NotifyResult();
42 58
59 scoped_refptr<safe_browsing::SafeBrowsingDatabaseManager> database_manager_;
43 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; 60 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_;
44 std::unique_ptr<SBDatabaseClient, base::OnTaskRunnerDeleter> database_client_; 61
62 int current_request_id_ = 0;
63 int last_received_request_id_ = 0;
64
65 // Cached check results to be forwarded in WillProessResponse.
66 safe_browsing::SBThreatType threat_type_ =
67 safe_browsing::SBThreatType::SB_THREAT_TYPE_SAFE;
68 safe_browsing::ThreatPatternType pattern_type_ =
69 safe_browsing::ThreatPatternType::NONE;
70
71 std::unique_ptr<SubresourceFilterSafeBrowsingClient,
72 base::OnTaskRunnerDeleter>
73 database_client_;
74
75 // Set to TimeTicks::Now() when the navigation is deferred in
76 // WillProcessResponse. If deferral was not necessary, will remain null.
77 base::TimeTicks defer_time_;
45 78
46 DISALLOW_COPY_AND_ASSIGN(SubresourceFilterSafeBrowsingActivationThrottle); 79 DISALLOW_COPY_AND_ASSIGN(SubresourceFilterSafeBrowsingActivationThrottle);
47 }; 80 };
48 81
49 } // namespace subresource_filter 82 } // namespace subresource_filter
50 83
51 #endif // COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_SUBRESOURCE_FILTER_SAFE _BROWSING_ACTIVATION_THROTTLE_H_ 84 #endif // COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_SUBRESOURCE_FILTER_SAFE _BROWSING_ACTIVATION_THROTTLE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698