OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/supervised_user/supervised_user_navigation_throttle.h" | 5 #include "chrome/browser/supervised_user/supervised_user_navigation_throttle.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 GURL url = navigation_handle()->GetURL(); | 152 GURL url = navigation_handle()->GetURL(); |
153 bool got_result = url_filter_->GetFilteringBehaviorForURLWithAsyncChecks( | 153 bool got_result = url_filter_->GetFilteringBehaviorForURLWithAsyncChecks( |
154 url, base::Bind(&SupervisedUserNavigationThrottle::OnCheckDone, | 154 url, base::Bind(&SupervisedUserNavigationThrottle::OnCheckDone, |
155 weak_ptr_factory_.GetWeakPtr(), url)); | 155 weak_ptr_factory_.GetWeakPtr(), url)); |
156 DCHECK_EQ(got_result, behavior_ != SupervisedUserURLFilter::INVALID); | 156 DCHECK_EQ(got_result, behavior_ != SupervisedUserURLFilter::INVALID); |
157 // If we got a "not blocked" result synchronously, don't defer. | 157 // If we got a "not blocked" result synchronously, don't defer. |
158 deferred_ = !got_result || (behavior_ == SupervisedUserURLFilter::BLOCK); | 158 deferred_ = !got_result || (behavior_ == SupervisedUserURLFilter::BLOCK); |
159 if (got_result) | 159 if (got_result) |
160 behavior_ = SupervisedUserURLFilter::INVALID; | 160 behavior_ = SupervisedUserURLFilter::INVALID; |
161 if (deferred_) | 161 if (deferred_) |
162 return ThrottleCheckResult::DEFER; | 162 return NavigationThrottle::DEFER; |
163 return ThrottleCheckResult::PROCEED; | 163 return NavigationThrottle::PROCEED; |
164 } | 164 } |
165 | 165 |
166 void SupervisedUserNavigationThrottle::ShowInterstitial( | 166 void SupervisedUserNavigationThrottle::ShowInterstitial( |
167 const GURL& url, | 167 const GURL& url, |
168 supervised_user_error_page::FilteringBehaviorReason reason) { | 168 supervised_user_error_page::FilteringBehaviorReason reason) { |
169 // Don't show interstitial synchronously - it doesn't seem like a good idea to | 169 // Don't show interstitial synchronously - it doesn't seem like a good idea to |
170 // show an interstitial right in the middle of a call into a | 170 // show an interstitial right in the middle of a call into a |
171 // NavigationThrottle. This also lets OnInterstitialResult to be invoked | 171 // NavigationThrottle. This also lets OnInterstitialResult to be invoked |
172 // synchronously, once a callback is passed into the | 172 // synchronously, once a callback is passed into the |
173 // SupervisedUserNavigationObserver. | 173 // SupervisedUserNavigationObserver. |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 DCHECK(deferred_); | 244 DCHECK(deferred_); |
245 deferred_ = false; | 245 deferred_ = false; |
246 navigation_handle()->Resume(); | 246 navigation_handle()->Resume(); |
247 } | 247 } |
248 | 248 |
249 void SupervisedUserNavigationThrottle::Cancel() { | 249 void SupervisedUserNavigationThrottle::Cancel() { |
250 DCHECK(deferred_); | 250 DCHECK(deferred_); |
251 deferred_ = false; | 251 deferred_ = false; |
252 navigation_handle()->CancelDeferredNavigation(CANCEL); | 252 navigation_handle()->CancelDeferredNavigation(CANCEL); |
253 } | 253 } |
OLD | NEW |