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

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

Issue 2889913002: [subresource_filter] Remove Forwarding NavigationThrottles (Closed)
Patch Set: Remove silly forwarding throttles Created 3 years, 7 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 COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_CONTENT_SUBRESOURCE_FILTER _DRIVER_FACTORY_H_ 5 #ifndef COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_CONTENT_SUBRESOURCE_FILTER _DRIVER_FACTORY_H_
6 #define COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_CONTENT_SUBRESOURCE_FILTER _DRIVER_FACTORY_H_ 6 #define COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_CONTENT_SUBRESOURCE_FILTER _DRIVER_FACTORY_H_
7 7
8 #include <map>
9 #include <memory> 8 #include <memory>
10 #include <set>
11 #include <string>
12 #include <utility>
13 #include <vector>
14 9
15 #include "base/macros.h" 10 #include "base/macros.h"
16 #include "base/time/time.h"
17 #include "components/safe_browsing_db/util.h" 11 #include "components/safe_browsing_db/util.h"
18 #include "components/subresource_filter/content/browser/content_subresource_filt er_throttle_manager.h" 12 #include "components/subresource_filter/content/browser/content_subresource_filt er_throttle_manager.h"
19 #include "components/subresource_filter/core/browser/subresource_filter_features .h" 13 #include "components/subresource_filter/core/browser/subresource_filter_features .h"
20 #include "content/public/browser/web_contents_observer.h" 14 #include "content/public/browser/web_contents_observer.h"
21 #include "content/public/browser/web_contents_user_data.h" 15 #include "content/public/browser/web_contents_user_data.h"
22 #include "ui/base/page_transition_types.h" 16 #include "ui/base/page_transition_types.h"
23 #include "url/gurl.h" 17
18 namespace base {
19 class GURL;
20 } // namespace base
24 21
25 namespace content { 22 namespace content {
26 class WebContents; 23 class WebContents;
27 } // namespace content 24 } // namespace content
28 25
29 namespace safe_browsing { 26 namespace safe_browsing {
30 class SafeBrowsingServiceTest; 27 class SafeBrowsingServiceTest;
31 }; 28 };
32 29
33 namespace subresource_filter { 30 namespace subresource_filter {
34 31
35 class SubresourceFilterClient; 32 class SubresourceFilterClient;
36 enum class ActivationLevel; 33 enum class ActivationLevel;
37 enum class ActivationList; 34 enum class ActivationList;
38 35
39 using URLToActivationListsMap =
40 std::unordered_map<std::string, std::set<ActivationList>>;
41
42 // Controls the activation of subresource filtering for each page load in a 36 // Controls the activation of subresource filtering for each page load in a
43 // WebContents and is responsible for sending the activation signal to all the 37 // WebContents and is responsible for sending the activation signal to all the
44 // per-frame SubresourceFilterAgents on the renderer side. 38 // per-frame SubresourceFilterAgents on the renderer side.
45 class ContentSubresourceFilterDriverFactory 39 class ContentSubresourceFilterDriverFactory
46 : public content::WebContentsUserData< 40 : public content::WebContentsUserData<
47 ContentSubresourceFilterDriverFactory>, 41 ContentSubresourceFilterDriverFactory>,
48 public content::WebContentsObserver, 42 public content::WebContentsObserver,
49 public ContentSubresourceFilterThrottleManager::Delegate { 43 public ContentSubresourceFilterThrottleManager::Delegate {
50 public: 44 public:
51 // NOTE: ActivationDecision backs a UMA histogram, so it is append-only. 45 // NOTE: ActivationDecision backs a UMA histogram, so it is append-only.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 ui::PageTransition transition); 80 ui::PageTransition transition);
87 81
88 explicit ContentSubresourceFilterDriverFactory( 82 explicit ContentSubresourceFilterDriverFactory(
89 content::WebContents* web_contents, 83 content::WebContents* web_contents,
90 SubresourceFilterClient* client); 84 SubresourceFilterClient* client);
91 ~ContentSubresourceFilterDriverFactory() override; 85 ~ContentSubresourceFilterDriverFactory() override;
92 86
93 // Called when Safe Browsing detects that the |url| corresponding to the load 87 // Called when Safe Browsing detects that the |url| corresponding to the load
94 // of the main frame belongs to the blacklist with |threat_type|. If the 88 // of the main frame belongs to the blacklist with |threat_type|. If the
95 // blacklist is the Safe Browsing Social Engineering ads landing, then |url| 89 // blacklist is the Safe Browsing Social Engineering ads landing, then |url|
96 // and |redirects| are saved. 90 // and |redirects| are saved.
shivanisha 2017/05/18 19:54:21 Need to change the comment since |url| is no longe
Charlie Harrison 2017/05/18 20:22:41 Yeah actually the whole comment is wrong :/ I've c
97 void OnMainResourceMatchedSafeBrowsingBlacklist( 91 void OnMainResourceMatchedSafeBrowsingBlacklist(
98 const GURL& url, 92 content::NavigationHandle* navigation_handle,
99 safe_browsing::SBThreatType threat_type, 93 safe_browsing::SBThreatType threat_type,
100 safe_browsing::ThreatPatternType threat_type_metadata); 94 safe_browsing::ThreatPatternType threat_type_metadata);
101 95
102 // Reloads the page and inserts the host of its URL to the whitelist. 96 // Reloads the page and inserts the host of its URL to the whitelist.
103 void OnReloadRequested(); 97 void OnReloadRequested();
104 98
105 // Returns the |ActivationDecision| for the current main frame 99 // Returns the |ActivationDecision| for the current main frame
106 // document. 100 // document.
107 ActivationDecision GetActivationDecisionForLastCommittedPageLoad() const { 101 ActivationDecision GetActivationDecisionForLastCommittedPageLoad() const {
108 return activation_decision_; 102 return activation_decision_;
109 } 103 }
110 104
111 // ContentSubresourceFilterThrottleManager::Delegate: 105 // ContentSubresourceFilterThrottleManager::Delegate:
112 void OnFirstSubresourceLoadDisallowed() override; 106 void OnFirstSubresourceLoadDisallowed() override;
113 void WillProcessResponse(
114 content::NavigationHandle* navigation_handle) override;
115 107
116 ContentSubresourceFilterThrottleManager* throttle_manager() { 108 ContentSubresourceFilterThrottleManager* throttle_manager() {
117 return throttle_manager_.get(); 109 return throttle_manager_.get();
118 } 110 }
119 111
120 SubresourceFilterClient* client() { return client_; } 112 SubresourceFilterClient* client() { return client_; }
121 113
122 private: 114 private:
123 friend class ContentSubresourceFilterDriverFactoryTest; 115 friend class ContentSubresourceFilterDriverFactoryTest;
124 friend class safe_browsing::SafeBrowsingServiceTest; 116 friend class safe_browsing::SafeBrowsingServiceTest;
125 117
126 // content::WebContentsObserver: 118 // content::WebContentsObserver:
127 void DidStartNavigation( 119 void DidStartNavigation(
128 content::NavigationHandle* navigation_handle) override; 120 content::NavigationHandle* navigation_handle) override;
129 void DidFinishNavigation( 121 void DidFinishNavigation(
130 content::NavigationHandle* navigation_handle) override; 122 content::NavigationHandle* navigation_handle) override;
131 123
132 // Checks base on the value of |url| and current activation scope if 124 // Checks base on the value of |url| and current activation scope if
133 // activation signal should be sent. 125 // activation signal should be sent.
134 void ComputeActivationForMainFrameNavigation( 126 void ComputeActivationForMainFrameNavigation(
135 content::NavigationHandle* navigation_handle); 127 content::NavigationHandle* navigation_handle,
128 ActivationList matched_list);
136 129
137 // Returns whether a main-frame navigation to the given |url| satisfies the 130 // Returns whether a main-frame navigation to the given |url| satisfies the
138 // activation |conditions| of a given configuration, except for |priority|. 131 // activation |conditions| of a given configuration, except for |priority|.
139 bool DoesMainFrameURLSatisfyActivationConditions( 132 bool DoesMainFrameURLSatisfyActivationConditions(
140 const GURL& url, 133 const GURL& url,
141 const Configuration::ActivationConditions& conditions) const; 134 const Configuration::ActivationConditions& conditions,
142 135 ActivationList matched_list) const;
143 bool DidURLMatchActivationList(const GURL& url,
144 ActivationList activation_list) const;
145
146 void AddActivationListMatch(const GURL& url, ActivationList match_type);
147 136
148 // Must outlive this class. 137 // Must outlive this class.
149 SubresourceFilterClient* client_; 138 SubresourceFilterClient* client_;
150 139
151 std::unique_ptr<ContentSubresourceFilterThrottleManager> throttle_manager_; 140 std::unique_ptr<ContentSubresourceFilterThrottleManager> throttle_manager_;
152 141
153 // The activation decision corresponding to the most recently _started_ 142 // The activation decision corresponding to the most recently _started_
154 // non-same-document navigation in the main frame. 143 // non-same-document navigation in the main frame.
155 // 144 //
156 // The value is reset to ActivationDecision::UNKNOWN at the start of each such 145 // The value is reset to ActivationDecision::UNKNOWN at the start of each such
157 // navigation, and will not be assigned until the navigation successfully 146 // navigation, and will not be assigned until the navigation successfully
158 // reaches the WillProcessResponse stage (or successfully finishes if 147 // reaches the WillProcessResponse stage (or successfully finishes if
159 // throttles are not invoked). This means that after a cancelled or otherwise 148 // throttles are not invoked). This means that after a cancelled or otherwise
160 // unsuccessful navigation, the value will be left at UNKNOWN indefinitely. 149 // unsuccessful navigation, the value will be left at UNKNOWN indefinitely.
161 ActivationDecision activation_decision_ = 150 ActivationDecision activation_decision_ =
162 ActivationDecision::ACTIVATION_DISABLED; 151 ActivationDecision::ACTIVATION_DISABLED;
163 152
164 // The activation options corresponding to the most recently _committed_ 153 // The activation options corresponding to the most recently _committed_
165 // non-same-document navigation in the main frame. 154 // non-same-document navigation in the main frame.
166 // 155 //
167 // The value corresponding to the previous such navigation will be retained, 156 // The value corresponding to the previous such navigation will be retained,
168 // and the new value not assigned until a subsequent navigation successfully 157 // and the new value not assigned until a subsequent navigation successfully
169 // reaches the WillProcessResponse stage (or successfully finishes if 158 // reaches the WillProcessResponse stage (or successfully finishes if
170 // throttles are not invoked). 159 // throttles are not invoked).
171 Configuration::ActivationOptions activation_options_; 160 Configuration::ActivationOptions activation_options_;
172 161
173 URLToActivationListsMap activation_list_matches_;
174
175 DISALLOW_COPY_AND_ASSIGN(ContentSubresourceFilterDriverFactory); 162 DISALLOW_COPY_AND_ASSIGN(ContentSubresourceFilterDriverFactory);
176 }; 163 };
177 164
178 } // namespace subresource_filter 165 } // namespace subresource_filter
179 166
180 #endif // COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_CONTENT_SUBRESOURCE_FIL TER_DRIVER_FACTORY_H_ 167 #endif // COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_CONTENT_SUBRESOURCE_FIL TER_DRIVER_FACTORY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698