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

Side by Side Diff: chrome/browser/supervised_user/supervised_user_navigation_observer.cc

Issue 2776493005: Convert SupervisedUserResourceThrottle to a NavigationThrottle. (Closed)
Patch Set: Response to comments 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 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 "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "chrome/browser/history/history_service_factory.h" 10 #include "chrome/browser/history/history_service_factory.h"
(...skipping 19 matching lines...) Expand all
30 supervised_user_service_->RemoveObserver(this); 30 supervised_user_service_->RemoveObserver(this);
31 } 31 }
32 32
33 SupervisedUserNavigationObserver::SupervisedUserNavigationObserver( 33 SupervisedUserNavigationObserver::SupervisedUserNavigationObserver(
34 content::WebContents* web_contents) 34 content::WebContents* web_contents)
35 : content::WebContentsObserver(web_contents), weak_ptr_factory_(this) { 35 : content::WebContentsObserver(web_contents), weak_ptr_factory_(this) {
36 Profile* profile = 36 Profile* profile =
37 Profile::FromBrowserContext(web_contents->GetBrowserContext()); 37 Profile::FromBrowserContext(web_contents->GetBrowserContext());
38 supervised_user_service_ = 38 supervised_user_service_ =
39 SupervisedUserServiceFactory::GetForProfile(profile); 39 SupervisedUserServiceFactory::GetForProfile(profile);
40 url_filter_ = supervised_user_service_->GetURLFilterForUIThread(); 40 url_filter_ = supervised_user_service_->GetURLFilter();
41 supervised_user_service_->AddObserver(this); 41 supervised_user_service_->AddObserver(this);
42 } 42 }
43 43
44 // static 44 // static
45 void SupervisedUserNavigationObserver::OnRequestBlocked( 45 void SupervisedUserNavigationObserver::OnRequestBlocked(
46 const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter, 46 content::WebContents* web_contents,
47 const GURL& url, 47 const GURL& url,
48 supervised_user_error_page::FilteringBehaviorReason reason, 48 supervised_user_error_page::FilteringBehaviorReason reason,
49 const base::Callback<void(bool)>& callback) { 49 const base::Callback<void(bool)>& callback) {
50 content::WebContents* web_contents = web_contents_getter.Run();
51 if (!web_contents) {
52 content::BrowserThread::PostTask(
53 content::BrowserThread::IO, FROM_HERE, base::Bind(callback, false));
54 return;
55 }
56
57 SupervisedUserNavigationObserver* navigation_observer = 50 SupervisedUserNavigationObserver* navigation_observer =
58 SupervisedUserNavigationObserver::FromWebContents(web_contents); 51 SupervisedUserNavigationObserver::FromWebContents(web_contents);
59 if (navigation_observer) 52 if (navigation_observer)
60 navigation_observer->OnRequestBlockedInternal(url); 53 navigation_observer->OnRequestBlockedInternal(url);
61 54
62 // Show the interstitial. 55 // Show the interstitial.
63 const bool initial_page_load = true; 56 const bool initial_page_load = true;
64 SupervisedUserInterstitial::Show(web_contents, url, reason, initial_page_load, 57 SupervisedUserInterstitial::Show(web_contents, url, reason, initial_page_load,
65 callback); 58 callback);
66 } 59 }
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 if (url != web_contents()->GetLastCommittedURL()) 122 if (url != web_contents()->GetLastCommittedURL())
130 return; 123 return;
131 124
132 const bool initial_page_load = false; 125 const bool initial_page_load = false;
133 if (behavior == SupervisedUserURLFilter::FilteringBehavior::BLOCK) { 126 if (behavior == SupervisedUserURLFilter::FilteringBehavior::BLOCK) {
134 SupervisedUserInterstitial::Show(web_contents(), url, reason, 127 SupervisedUserInterstitial::Show(web_contents(), url, reason,
135 initial_page_load, 128 initial_page_load,
136 base::Callback<void(bool)>()); 129 base::Callback<void(bool)>());
137 } 130 }
138 } 131 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698