OLD | NEW |
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 #include "components/subresource_filter/content/browser/content_subresource_filt
er_driver_factory.h" | 5 #include "components/subresource_filter/content/browser/content_subresource_filt
er_driver_factory.h" |
6 | 6 |
7 #include "base/feature_list.h" | |
8 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
9 #include "base/metrics/histogram_macros.h" | |
10 #include "base/rand_util.h" | 8 #include "base/rand_util.h" |
11 #include "base/time/time.h" | 9 #include "base/time/time.h" |
12 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
13 #include "base/trace_event/trace_event_argument.h" | 11 #include "base/trace_event/trace_event_argument.h" |
14 #include "components/subresource_filter/content/browser/content_activation_list_
utils.h" | 12 #include "components/subresource_filter/content/browser/content_activation_list_
utils.h" |
15 #include "components/subresource_filter/content/browser/subresource_filter_clien
t.h" | 13 #include "components/subresource_filter/content/browser/subresource_filter_clien
t.h" |
16 #include "components/subresource_filter/core/browser/subresource_filter_features
.h" | 14 #include "components/subresource_filter/core/browser/subresource_filter_features
.h" |
17 #include "components/subresource_filter/core/common/activation_list.h" | 15 #include "components/subresource_filter/core/common/activation_list.h" |
18 #include "components/subresource_filter/core/common/activation_state.h" | 16 #include "components/subresource_filter/core/common/activation_state.h" |
19 #include "content/public/browser/navigation_handle.h" | 17 #include "content/public/browser/navigation_handle.h" |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 return true; | 148 return true; |
151 } | 149 } |
152 return false; | 150 return false; |
153 case ActivationScope::NO_SITES: | 151 case ActivationScope::NO_SITES: |
154 return false; | 152 return false; |
155 } | 153 } |
156 NOTREACHED(); | 154 NOTREACHED(); |
157 return false; | 155 return false; |
158 } | 156 } |
159 | 157 |
160 void ContentSubresourceFilterDriverFactory::OnReloadRequested() { | |
161 UMA_HISTOGRAM_BOOLEAN("SubresourceFilter.Prompt.NumReloads", true); | |
162 const GURL& whitelist_url = web_contents()->GetLastCommittedURL(); | |
163 | |
164 // Only whitelist via content settings when using the experimental UI, | |
165 // otherwise could get into a situation where content settings cannot be | |
166 // adjusted. | |
167 if (base::FeatureList::IsEnabled( | |
168 subresource_filter::kSafeBrowsingSubresourceFilterExperimentalUI)) { | |
169 client_->WhitelistByContentSettings(whitelist_url); | |
170 } else { | |
171 client_->WhitelistInCurrentWebContents(whitelist_url); | |
172 } | |
173 web_contents()->GetController().Reload(content::ReloadType::NORMAL, true); | |
174 } | |
175 | |
176 void ContentSubresourceFilterDriverFactory::WillProcessResponse( | 158 void ContentSubresourceFilterDriverFactory::WillProcessResponse( |
177 content::NavigationHandle* navigation_handle) { | 159 content::NavigationHandle* navigation_handle) { |
178 DCHECK(!navigation_handle->IsSameDocument()); | 160 DCHECK(!navigation_handle->IsSameDocument()); |
179 if (!navigation_handle->IsInMainFrame() || | 161 if (!navigation_handle->IsInMainFrame() || |
180 navigation_handle->GetNetErrorCode() != net::OK) { | 162 navigation_handle->GetNetErrorCode() != net::OK) { |
181 return; | 163 return; |
182 } | 164 } |
183 | 165 |
184 const GURL& url = navigation_handle->GetURL(); | 166 const GURL& url = navigation_handle->GetURL(); |
185 const content::Referrer& referrer = navigation_handle->GetReferrer(); | 167 const content::Referrer& referrer = navigation_handle->GetReferrer(); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 void ContentSubresourceFilterDriverFactory::AddActivationListMatch( | 244 void ContentSubresourceFilterDriverFactory::AddActivationListMatch( |
263 const GURL& url, | 245 const GURL& url, |
264 ActivationList match_type) { | 246 ActivationList match_type) { |
265 if (match_type == ActivationList::NONE) | 247 if (match_type == ActivationList::NONE) |
266 return; | 248 return; |
267 if (url.has_host() && url.SchemeIsHTTPOrHTTPS()) | 249 if (url.has_host() && url.SchemeIsHTTPOrHTTPS()) |
268 activation_list_matches_[DistillURLToHostAndPath(url)].insert(match_type); | 250 activation_list_matches_[DistillURLToHostAndPath(url)].insert(match_type); |
269 } | 251 } |
270 | 252 |
271 } // namespace subresource_filter | 253 } // namespace subresource_filter |
OLD | NEW |