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

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

Issue 2890253002: [subresource_filter] Move OnReloadRequested to the ChromeClient (Closed)
Patch Set: rebase on #473448 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 #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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 return true; 207 return true;
210 } 208 }
211 return false; 209 return false;
212 case ActivationScope::NO_SITES: 210 case ActivationScope::NO_SITES:
213 return false; 211 return false;
214 } 212 }
215 NOTREACHED(); 213 NOTREACHED();
216 return false; 214 return false;
217 } 215 }
218 216
219 void ContentSubresourceFilterDriverFactory::OnReloadRequested() {
220 UMA_HISTOGRAM_BOOLEAN("SubresourceFilter.Prompt.NumReloads", true);
221 const GURL& whitelist_url = web_contents()->GetLastCommittedURL();
222
223 // Only whitelist via content settings when using the experimental UI,
224 // otherwise could get into a situation where content settings cannot be
225 // adjusted.
226 if (base::FeatureList::IsEnabled(
227 subresource_filter::kSafeBrowsingSubresourceFilterExperimentalUI)) {
228 client_->WhitelistByContentSettings(whitelist_url);
229 } else {
230 client_->WhitelistInCurrentWebContents(whitelist_url);
231 }
232 web_contents()->GetController().Reload(content::ReloadType::NORMAL, true);
233 }
234
235 void ContentSubresourceFilterDriverFactory::OnFirstSubresourceLoadDisallowed() { 217 void ContentSubresourceFilterDriverFactory::OnFirstSubresourceLoadDisallowed() {
236 if (activation_options_.should_suppress_notifications) 218 if (activation_options_.should_suppress_notifications)
237 return; 219 return;
238 client_->ToggleNotificationVisibility(activation_options_.activation_level == 220 client_->ToggleNotificationVisibility(activation_options_.activation_level ==
239 ActivationLevel::ENABLED); 221 ActivationLevel::ENABLED);
240 } 222 }
241 223
242 void ContentSubresourceFilterDriverFactory::DidStartNavigation( 224 void ContentSubresourceFilterDriverFactory::DidStartNavigation(
243 content::NavigationHandle* navigation_handle) { 225 content::NavigationHandle* navigation_handle) {
244 if (navigation_handle->IsInMainFrame() && 226 if (navigation_handle->IsInMainFrame() &&
245 !navigation_handle->IsSameDocument()) { 227 !navigation_handle->IsSameDocument()) {
246 activation_decision_ = ActivationDecision::UNKNOWN; 228 activation_decision_ = ActivationDecision::UNKNOWN;
247 client_->ToggleNotificationVisibility(false); 229 client_->ToggleNotificationVisibility(false);
248 } 230 }
249 } 231 }
250 232
251 void ContentSubresourceFilterDriverFactory::DidFinishNavigation( 233 void ContentSubresourceFilterDriverFactory::DidFinishNavigation(
252 content::NavigationHandle* navigation_handle) { 234 content::NavigationHandle* navigation_handle) {
253 if (navigation_handle->IsInMainFrame() && 235 if (navigation_handle->IsInMainFrame() &&
254 !navigation_handle->IsSameDocument() && 236 !navigation_handle->IsSameDocument() &&
255 activation_decision_ == ActivationDecision::UNKNOWN && 237 activation_decision_ == ActivationDecision::UNKNOWN &&
256 navigation_handle->HasCommitted()) { 238 navigation_handle->HasCommitted()) {
257 activation_decision_ = ActivationDecision::ACTIVATION_DISABLED; 239 activation_decision_ = ActivationDecision::ACTIVATION_DISABLED;
258 activation_options_ = Configuration::ActivationOptions(); 240 activation_options_ = Configuration::ActivationOptions();
259 } 241 }
260 } 242 }
261 243
262 } // namespace subresource_filter 244 } // namespace subresource_filter
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698