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

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

Issue 2844063002: Add support for multiple simultaneous subresource_filter::Configurations. (Closed)
Patch Set: Polish + rebase. 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> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <set> 10 #include <set>
11 #include <string> 11 #include <string>
12 #include <utility> 12 #include <utility>
13 #include <vector> 13 #include <vector>
14 14
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/supports_user_data.h" 16 #include "base/supports_user_data.h"
17 #include "base/time/time.h" 17 #include "base/time/time.h"
18 #include "components/safe_browsing_db/util.h" 18 #include "components/safe_browsing_db/util.h"
19 #include "components/subresource_filter/content/browser/content_subresource_filt er_throttle_manager.h" 19 #include "components/subresource_filter/content/browser/content_subresource_filt er_throttle_manager.h"
20 #include "components/subresource_filter/core/browser/subresource_filter_features .h"
20 #include "content/public/browser/web_contents_observer.h" 21 #include "content/public/browser/web_contents_observer.h"
21 #include "ui/base/page_transition_types.h" 22 #include "ui/base/page_transition_types.h"
22 #include "url/gurl.h" 23 #include "url/gurl.h"
23 24
24 namespace content { 25 namespace content {
25 class WebContents; 26 class WebContents;
26 } // namespace content 27 } // namespace content
27 28
28 namespace safe_browsing { 29 namespace safe_browsing {
29 class SafeBrowsingServiceTest; 30 class SafeBrowsingServiceTest;
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 ContentSubresourceFilterThrottleManager* throttle_manager() { 119 ContentSubresourceFilterThrottleManager* throttle_manager() {
119 return throttle_manager_.get(); 120 return throttle_manager_.get();
120 } 121 }
121 122
122 SubresourceFilterClient* client() { return client_.get(); } 123 SubresourceFilterClient* client() { return client_.get(); }
123 124
124 private: 125 private:
125 friend class ContentSubresourceFilterDriverFactoryTest; 126 friend class ContentSubresourceFilterDriverFactoryTest;
126 friend class safe_browsing::SafeBrowsingServiceTest; 127 friend class safe_browsing::SafeBrowsingServiceTest;
127 128
128 void ResetActivationState();
129
130 // content::WebContentsObserver: 129 // content::WebContentsObserver:
131 void DidStartNavigation( 130 void DidStartNavigation(
132 content::NavigationHandle* navigation_handle) override; 131 content::NavigationHandle* navigation_handle) override;
133 void DidRedirectNavigation( 132 void DidRedirectNavigation(
134 content::NavigationHandle* navigation_handle) override; 133 content::NavigationHandle* navigation_handle) override;
134 void DidFinishNavigation(
135 content::NavigationHandle* navigation_handle) override;
135 136
136 // Checks base on the value of |url| and current activation scope if 137 // Checks base on the value of |url| and current activation scope if
137 // activation signal should be sent. 138 // activation signal should be sent.
138 ActivationDecision ComputeActivationDecisionForMainFrameNavigation( 139 void ComputeActivationForMainFrameNavigation(
139 content::NavigationHandle* navigation_handle) const; 140 content::NavigationHandle* navigation_handle);
141 ActivationDecision ComputePerConfigActivationDecisionForMainFrameNavigation(
142 content::NavigationHandle* navigation_handle,
143 const Configuration& configuration) const;
140 144
141 bool DidURLMatchActivationList(const GURL& url, 145 bool DidURLMatchActivationList(const GURL& url,
142 ActivationList activation_list) const; 146 ActivationList activation_list) const;
143 147
144 void AddActivationListMatch(const GURL& url, ActivationList match_type); 148 void AddActivationListMatch(const GURL& url, ActivationList match_type);
145 int CalculateHitPatternForActivationList( 149 int CalculateHitPatternForActivationList(
146 ActivationList activation_list) const; 150 ActivationList activation_list) const;
147 void RecordRedirectChainMatchPattern() const; 151 void RecordRedirectChainMatchPattern() const;
148 152
149 void RecordRedirectChainMatchPatternForList( 153 void RecordRedirectChainMatchPatternForList(
150 ActivationList activation_list) const; 154 ActivationList activation_list) const;
151 155
152 std::unique_ptr<SubresourceFilterClient> client_; 156 std::unique_ptr<SubresourceFilterClient> client_;
153 157
154 std::unique_ptr<ContentSubresourceFilterThrottleManager> throttle_manager_; 158 std::unique_ptr<ContentSubresourceFilterThrottleManager> throttle_manager_;
155 159
156 ActivationLevel activation_level_; 160 // The activation decision corresponding to the most recently _started_
Charlie Harrison 2017/05/03 14:52:17 Optional: Since driver factory is going away this
engedy 2017/05/05 12:25:41 We discussed offline that due to subtle timing con
Charlie Harrison 2017/05/05 13:12:52 I think keeping as-is is ok, and we'll rethink onc
157 ActivationDecision activation_decision_; 161 // non-same-document navigation in the main frame.
158 bool measure_performance_; 162 //
163 // The value is reset to ActivationDecision::UNKNOWN at the start of each such
164 // navigation, and will not be assigned until the navigation successfully
165 // reaches the WillProcessResponse stage (or successfully finishes if
166 // throttles are not invoked). This means that after a cancelled or otherwise
167 // unsuccessful navigation, the value will be left at UNKNOWN indefinitely.
168 ActivationDecision activation_decision_ =
169 ActivationDecision::ACTIVATION_DISABLED;
170
171 // The activation options corresponding to the most recently _committed_
172 // non-same-document navigation in the main frame.
173 //
174 // The value corresponding to the previous such navigation will be retained,
175 // and the new value not assigned until a subsequent navigation successfully
176 // reaches the WillProcessResponse stage (or successfully finishes if
177 // throttles are not invoked).
178 Configuration::ActivationOptions activation_options_;
159 179
160 // The URLs in the navigation chain. 180 // The URLs in the navigation chain.
161 std::vector<GURL> navigation_chain_; 181 std::vector<GURL> navigation_chain_;
162 182
163 URLToActivationListsMap activation_list_matches_; 183 URLToActivationListsMap activation_list_matches_;
164 184
165 DISALLOW_COPY_AND_ASSIGN(ContentSubresourceFilterDriverFactory); 185 DISALLOW_COPY_AND_ASSIGN(ContentSubresourceFilterDriverFactory);
166 }; 186 };
167 187
168 } // namespace subresource_filter 188 } // namespace subresource_filter
169 189
170 #endif // COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_CONTENT_SUBRESOURCE_FIL TER_DRIVER_FACTORY_H_ 190 #endif // COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_CONTENT_SUBRESOURCE_FIL TER_DRIVER_FACTORY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698