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

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

Issue 2798983002: Introduce subresource_filter::Configuration. (Closed)
Patch Set: Rebase. 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 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 "components/subresource_filter/core/common/document_load_statistics.h" 21 #include "components/subresource_filter/core/common/document_load_statistics.h"
21 #include "content/public/browser/web_contents_observer.h" 22 #include "content/public/browser/web_contents_observer.h"
22 #include "ui/base/page_transition_types.h" 23 #include "ui/base/page_transition_types.h"
23 #include "url/gurl.h" 24 #include "url/gurl.h"
24 25
25 namespace content { 26 namespace content {
26 class WebContents; 27 class WebContents;
27 class RenderFrameHost; 28 class RenderFrameHost;
28 } // namespace content 29 } // namespace content
29 30
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 void OnFirstSubresourceLoadDisallowed() override; 121 void OnFirstSubresourceLoadDisallowed() override;
121 bool ShouldSuppressActivation( 122 bool ShouldSuppressActivation(
122 content::NavigationHandle* navigation_handle) override; 123 content::NavigationHandle* navigation_handle) override;
123 void WillProcessResponse( 124 void WillProcessResponse(
124 content::NavigationHandle* navigation_handle) override; 125 content::NavigationHandle* navigation_handle) override;
125 126
126 ContentSubresourceFilterThrottleManager* throttle_manager() { 127 ContentSubresourceFilterThrottleManager* throttle_manager() {
127 return throttle_manager_.get(); 128 return throttle_manager_.get();
128 } 129 }
129 130
131 // TODO(https://crbug.com/708181): Allow tests to change the configuration
132 // after construction (which happens at WebContents creation) but before a
133 // navigation start. Can be removed once the Safe Browsing navigation throttle
134 // handles all activation decisions.
135 void set_configuration_for_testing(Configuration configuration) {
136 configuration_ = std::move(configuration);
137 }
138
130 private: 139 private:
131 friend class ContentSubresourceFilterDriverFactoryTest; 140 friend class ContentSubresourceFilterDriverFactoryTest;
132 friend class safe_browsing::SafeBrowsingServiceTest; 141 friend class safe_browsing::SafeBrowsingServiceTest;
133 142
134 void ResetActivationState(); 143 void ResetActivationState();
135 144
136 void OnDocumentLoadStatistics(const DocumentLoadStatistics& statistics); 145 void OnDocumentLoadStatistics(const DocumentLoadStatistics& statistics);
137 146
138 bool IsWhitelisted(const GURL& url) const; 147 bool IsWhitelisted(const GURL& url) const;
139 148
(...skipping 16 matching lines...) Expand all
156 ActivationList activation_list) const; 165 ActivationList activation_list) const;
157 166
158 void AddActivationListMatch(const GURL& url, ActivationList match_type); 167 void AddActivationListMatch(const GURL& url, ActivationList match_type);
159 int CalculateHitPatternForActivationList( 168 int CalculateHitPatternForActivationList(
160 ActivationList activation_list) const; 169 ActivationList activation_list) const;
161 void RecordRedirectChainMatchPattern() const; 170 void RecordRedirectChainMatchPattern() const;
162 171
163 void RecordRedirectChainMatchPatternForList( 172 void RecordRedirectChainMatchPatternForList(
164 ActivationList activation_list) const; 173 ActivationList activation_list) const;
165 174
175 Configuration configuration_;
176
166 std::unique_ptr<SubresourceFilterClient> client_; 177 std::unique_ptr<SubresourceFilterClient> client_;
167 178
168 std::unique_ptr<ContentSubresourceFilterThrottleManager> throttle_manager_; 179 std::unique_ptr<ContentSubresourceFilterThrottleManager> throttle_manager_;
169 180
170 // Hosts to whitelist. This is only used for per-WebContents whitelisting and 181 // Hosts to whitelist. This is only used for per-WebContents whitelisting and
171 // is distinct from content settings whitelisting. 182 // is distinct from content settings whitelisting.
172 HostPathSet whitelisted_hosts_; 183 HostPathSet whitelisted_hosts_;
173 184
174 ActivationLevel activation_level_; 185 ActivationLevel activation_level_;
175 ActivationDecision activation_decision_; 186 ActivationDecision activation_decision_;
176 bool measure_performance_; 187 bool measure_performance_;
177 188
178 // The URLs in the navigation chain. 189 // The URLs in the navigation chain.
179 std::vector<GURL> navigation_chain_; 190 std::vector<GURL> navigation_chain_;
180 191
181 URLToActivationListsMap activation_list_matches_; 192 URLToActivationListsMap activation_list_matches_;
182 193
183 // Statistics about subresource loads, aggregated across all frames of the 194 // Statistics about subresource loads, aggregated across all frames of the
184 // current page. 195 // current page.
185 DocumentLoadStatistics aggregated_document_statistics_; 196 DocumentLoadStatistics aggregated_document_statistics_;
186 197
187 DISALLOW_COPY_AND_ASSIGN(ContentSubresourceFilterDriverFactory); 198 DISALLOW_COPY_AND_ASSIGN(ContentSubresourceFilterDriverFactory);
188 }; 199 };
189 200
190 } // namespace subresource_filter 201 } // namespace subresource_filter
191 202
192 #endif // COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_CONTENT_SUBRESOURCE_FIL TER_DRIVER_FACTORY_H_ 203 #endif // COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_CONTENT_SUBRESOURCE_FIL TER_DRIVER_FACTORY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698