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

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: 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/time/time.h" 16 #include "base/time/time.h"
17 #include "components/safe_browsing_db/util.h" 17 #include "components/safe_browsing_db/util.h"
18 #include "components/subresource_filter/content/browser/content_subresource_filt er_throttle_manager.h" 18 #include "components/subresource_filter/content/browser/content_subresource_filt er_throttle_manager.h"
19 #include "components/subresource_filter/core/browser/subresource_filter_features .h"
19 #include "content/public/browser/web_contents_observer.h" 20 #include "content/public/browser/web_contents_observer.h"
20 #include "content/public/browser/web_contents_user_data.h" 21 #include "content/public/browser/web_contents_user_data.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 {
(...skipping 19 matching lines...) Expand all
48 public ContentSubresourceFilterThrottleManager::Delegate { 49 public ContentSubresourceFilterThrottleManager::Delegate {
49 public: 50 public:
50 // NOTE: ActivationDecision backs a UMA histogram, so it is append-only. 51 // NOTE: ActivationDecision backs a UMA histogram, so it is append-only.
51 enum class ActivationDecision { 52 enum class ActivationDecision {
52 // The activation decision is unknown, or not known yet. 53 // The activation decision is unknown, or not known yet.
53 UNKNOWN, 54 UNKNOWN,
54 55
55 // Subresource filtering was activated. 56 // Subresource filtering was activated.
56 ACTIVATED, 57 ACTIVATED,
57 58
58 // Did not activate because subresource filtering was disabled. 59 // Did not activate because subresource filtering was disabled by the
60 // highest priority configuration whose activation conditions were met.
59 ACTIVATION_DISABLED, 61 ACTIVATION_DISABLED,
60 62
61 // Did not activate because the main frame document URL had an unsupported 63 // Did not activate because the main frame document URL had an unsupported
62 // scheme. 64 // scheme.
63 UNSUPPORTED_SCHEME, 65 UNSUPPORTED_SCHEME,
64 66
65 // Did not activate because the main frame document URL was whitelisted. 67 // Did not activate because although there was a configuration whose
68 // activation conditions were met, the main frame URL was whitelisted.
66 URL_WHITELISTED, 69 URL_WHITELISTED,
67 70
68 // Did not activate because the main frame document URL did not match the 71 // Did not activate because the main frame document URL did not match the
69 // activation list. 72 // activation conditions of any of enabled configurations.
70 ACTIVATION_LIST_NOT_MATCHED, 73 ACTIVATION_CONDITIONS_NOT_MET,
71 74
72 // Max value for enum. 75 // Max value for enum.
73 ACTIVATION_DECISION_MAX 76 ACTIVATION_DECISION_MAX
74 }; 77 };
75 78
76 static void CreateForWebContents(content::WebContents* web_contents, 79 static void CreateForWebContents(content::WebContents* web_contents,
77 SubresourceFilterClient* client); 80 SubresourceFilterClient* client);
78 81
79 // Whether the |url|, |referrer|, and |transition| are considered to be 82 // Whether the |url|, |referrer|, and |transition| are considered to be
80 // associated with a page reload. 83 // associated with a page reload.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 ContentSubresourceFilterThrottleManager* throttle_manager() { 119 ContentSubresourceFilterThrottleManager* throttle_manager() {
117 return throttle_manager_.get(); 120 return throttle_manager_.get();
118 } 121 }
119 122
120 SubresourceFilterClient* client() { return client_; } 123 SubresourceFilterClient* client() { return client_; }
121 124
122 private: 125 private:
123 friend class ContentSubresourceFilterDriverFactoryTest; 126 friend class ContentSubresourceFilterDriverFactoryTest;
124 friend class safe_browsing::SafeBrowsingServiceTest; 127 friend class safe_browsing::SafeBrowsingServiceTest;
125 128
126 void ResetActivationState();
127
128 // content::WebContentsObserver: 129 // content::WebContentsObserver:
129 void DidStartNavigation( 130 void DidStartNavigation(
130 content::NavigationHandle* navigation_handle) override; 131 content::NavigationHandle* navigation_handle) override;
131 void DidRedirectNavigation( 132 void DidRedirectNavigation(
132 content::NavigationHandle* navigation_handle) override; 133 content::NavigationHandle* navigation_handle) override;
134 void DidFinishNavigation(
135 content::NavigationHandle* navigation_handle) override;
133 136
134 // 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
135 // activation signal should be sent. 138 // activation signal should be sent.
136 ActivationDecision ComputeActivationDecisionForMainFrameNavigation( 139 void ComputeActivationForMainFrameNavigation(
137 content::NavigationHandle* navigation_handle) const; 140 content::NavigationHandle* navigation_handle);
141
142 // Returns whether a main-frame navigation to the given |url| satisfies the
143 // activation |conditions| of a given configuration, except for |priority|.
144 bool DoesMainFrameURLSatisfyActivationConditions(
145 const GURL& url,
146 const Configuration::ActivationConditions& conditions) const;
138 147
139 bool DidURLMatchActivationList(const GURL& url, 148 bool DidURLMatchActivationList(const GURL& url,
140 ActivationList activation_list) const; 149 ActivationList activation_list) const;
141 150
142 void AddActivationListMatch(const GURL& url, ActivationList match_type); 151 void AddActivationListMatch(const GURL& url, ActivationList match_type);
143 int CalculateHitPatternForActivationList( 152 int CalculateHitPatternForActivationList(
144 ActivationList activation_list) const; 153 ActivationList activation_list) const;
145 void RecordRedirectChainMatchPattern() const; 154 void RecordRedirectChainMatchPattern() const;
146 155
147 void RecordRedirectChainMatchPatternForList( 156 void RecordRedirectChainMatchPatternForList(
148 ActivationList activation_list) const; 157 ActivationList activation_list) const;
149 158
150 // Must outlive this class. 159 // Must outlive this class.
151 SubresourceFilterClient* client_; 160 SubresourceFilterClient* client_;
152 161
153 std::unique_ptr<ContentSubresourceFilterThrottleManager> throttle_manager_; 162 std::unique_ptr<ContentSubresourceFilterThrottleManager> throttle_manager_;
154 163
155 ActivationLevel activation_level_; 164 // The activation decision corresponding to the most recently _started_
156 ActivationDecision activation_decision_; 165 // non-same-document navigation in the main frame.
157 bool measure_performance_; 166 //
167 // The value is reset to ActivationDecision::UNKNOWN at the start of each such
168 // navigation, and will not be assigned until the navigation successfully
169 // reaches the WillProcessResponse stage (or successfully finishes if
170 // throttles are not invoked). This means that after a cancelled or otherwise
171 // unsuccessful navigation, the value will be left at UNKNOWN indefinitely.
172 ActivationDecision activation_decision_ =
173 ActivationDecision::ACTIVATION_DISABLED;
174
175 // The activation options corresponding to the most recently _committed_
176 // non-same-document navigation in the main frame.
177 //
178 // The value corresponding to the previous such navigation will be retained,
179 // and the new value not assigned until a subsequent navigation successfully
180 // reaches the WillProcessResponse stage (or successfully finishes if
181 // throttles are not invoked).
182 Configuration::ActivationOptions activation_options_;
158 183
159 // The URLs in the navigation chain. 184 // The URLs in the navigation chain.
160 std::vector<GURL> navigation_chain_; 185 std::vector<GURL> navigation_chain_;
161 186
162 URLToActivationListsMap activation_list_matches_; 187 URLToActivationListsMap activation_list_matches_;
163 188
164 DISALLOW_COPY_AND_ASSIGN(ContentSubresourceFilterDriverFactory); 189 DISALLOW_COPY_AND_ASSIGN(ContentSubresourceFilterDriverFactory);
165 }; 190 };
166 191
167 } // namespace subresource_filter 192 } // namespace subresource_filter
168 193
169 #endif // COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_CONTENT_SUBRESOURCE_FIL TER_DRIVER_FACTORY_H_ 194 #endif // COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_CONTENT_SUBRESOURCE_FIL TER_DRIVER_FACTORY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698