| 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_observer.h" | 5 #include "chrome/browser/supervised_user/supervised_user_navigation_observer.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "chrome/browser/history/history_service_factory.h" | 9 #include "chrome/browser/history/history_service_factory.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 supervised_user_service_ = | 36 supervised_user_service_ = |
| 37 SupervisedUserServiceFactory::GetForProfile(profile); | 37 SupervisedUserServiceFactory::GetForProfile(profile); |
| 38 url_filter_ = supervised_user_service_->GetURLFilterForUIThread(); | 38 url_filter_ = supervised_user_service_->GetURLFilterForUIThread(); |
| 39 supervised_user_service_->AddObserver(this); | 39 supervised_user_service_->AddObserver(this); |
| 40 } | 40 } |
| 41 | 41 |
| 42 // static | 42 // static |
| 43 void SupervisedUserNavigationObserver::OnRequestBlocked( | 43 void SupervisedUserNavigationObserver::OnRequestBlocked( |
| 44 const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter, | 44 const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter, |
| 45 const GURL& url, | 45 const GURL& url, |
| 46 SupervisedUserURLFilter::FilteringBehaviorReason reason, | 46 supervised_user_error_page::FilteringBehaviorReason reason, |
| 47 const base::Callback<void(bool)>& callback) { | 47 const base::Callback<void(bool)>& callback) { |
| 48 content::WebContents* web_contents = web_contents_getter.Run(); | 48 content::WebContents* web_contents = web_contents_getter.Run(); |
| 49 if (!web_contents) { | 49 if (!web_contents) { |
| 50 content::BrowserThread::PostTask( | 50 content::BrowserThread::PostTask( |
| 51 content::BrowserThread::IO, FROM_HERE, base::Bind(callback, false)); | 51 content::BrowserThread::IO, FROM_HERE, base::Bind(callback, false)); |
| 52 return; | 52 return; |
| 53 } | 53 } |
| 54 | 54 |
| 55 SupervisedUserNavigationObserver* navigation_observer = | 55 SupervisedUserNavigationObserver* navigation_observer = |
| 56 SupervisedUserNavigationObserver::FromWebContents(web_contents); | 56 SupervisedUserNavigationObserver::FromWebContents(web_contents); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 url_filter_->GetFilteringBehaviorForURLWithAsyncChecks( | 97 url_filter_->GetFilteringBehaviorForURLWithAsyncChecks( |
| 98 web_contents_->GetLastCommittedURL(), | 98 web_contents_->GetLastCommittedURL(), |
| 99 base::Bind(&SupervisedUserNavigationObserver::URLFilterCheckCallback, | 99 base::Bind(&SupervisedUserNavigationObserver::URLFilterCheckCallback, |
| 100 weak_ptr_factory_.GetWeakPtr(), | 100 weak_ptr_factory_.GetWeakPtr(), |
| 101 web_contents_->GetLastCommittedURL())); | 101 web_contents_->GetLastCommittedURL())); |
| 102 } | 102 } |
| 103 | 103 |
| 104 void SupervisedUserNavigationObserver::URLFilterCheckCallback( | 104 void SupervisedUserNavigationObserver::URLFilterCheckCallback( |
| 105 const GURL& url, | 105 const GURL& url, |
| 106 SupervisedUserURLFilter::FilteringBehavior behavior, | 106 SupervisedUserURLFilter::FilteringBehavior behavior, |
| 107 SupervisedUserURLFilter::FilteringBehaviorReason reason, | 107 supervised_user_error_page::FilteringBehaviorReason reason, |
| 108 bool uncertain) { | 108 bool uncertain) { |
| 109 // If the page has been changed in the meantime, we can exit. | 109 // If the page has been changed in the meantime, we can exit. |
| 110 if (url != web_contents_->GetLastCommittedURL()) | 110 if (url != web_contents_->GetLastCommittedURL()) |
| 111 return; | 111 return; |
| 112 | 112 |
| 113 if (behavior == SupervisedUserURLFilter::FilteringBehavior::BLOCK) { | 113 if (behavior == SupervisedUserURLFilter::FilteringBehavior::BLOCK) { |
| 114 SupervisedUserInterstitial::Show(web_contents_, url, reason, | 114 SupervisedUserInterstitial::Show(web_contents_, url, reason, |
| 115 base::Callback<void(bool)>()); | 115 base::Callback<void(bool)>()); |
| 116 } | 116 } |
| 117 } | 117 } |
| OLD | NEW |