blob: 96d022dda51d81108bf3a546c29a9eea04e4e6d6 [file] [log] [blame]
[email protected]cce15bb2014-06-17 13:43:511// Copyright 2014 The Chromium Authors. All rights reserved.
[email protected]a09159a2012-11-29 12:51:482// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]cce15bb2014-06-17 13:43:515#include "chrome/browser/supervised_user/supervised_user_interstitial.h"
[email protected]a09159a2012-11-29 12:51:486
treibe7ccb7e2014-09-09 19:21:457#include "base/memory/weak_ptr.h"
[email protected]2c145422013-01-24 18:15:408#include "base/metrics/histogram.h"
[email protected]3853a4c2013-02-11 17:15:579#include "base/prefs/pref_service.h"
[email protected]95c47d02014-08-19 09:17:5010#include "base/strings/string_number_conversions.h"
khannansf3b27192015-01-09 17:28:1711#include "base/strings/stringprintf.h"
[email protected]112158af2013-06-07 23:46:1812#include "base/strings/utf_string_conversions.h"
[email protected]59f21562013-05-23 16:19:3013#include "base/values.h"
[email protected]93c23212013-09-19 14:22:3814#include "chrome/browser/infobars/infobar_service.h"
[email protected]a09159a2012-11-29 12:51:4815#include "chrome/browser/profiles/profile.h"
[email protected]cce15bb2014-06-17 13:43:5116#include "chrome/browser/supervised_user/supervised_user_service.h"
17#include "chrome/browser/supervised_user/supervised_user_service_factory.h"
[email protected]a09159a2012-11-29 12:51:4818#include "chrome/common/pref_names.h"
[email protected]af39f002014-08-22 10:18:1819#include "chrome/grit/generated_resources.h"
[email protected]051655ad2014-04-18 15:09:4120#include "components/infobars/core/infobar.h"
21#include "components/infobars/core/infobar_delegate.h"
[email protected]a09159a2012-11-29 12:51:4822#include "content/public/browser/browser_thread.h"
23#include "content/public/browser/interstitial_page.h"
[email protected]93c23212013-09-19 14:22:3824#include "content/public/browser/navigation_controller.h"
25#include "content/public/browser/navigation_details.h"
26#include "content/public/browser/navigation_entry.h"
khannansf3b27192015-01-09 17:28:1727#include "content/public/browser/render_frame_host.h"
28#include "content/public/browser/render_view_host.h"
[email protected]a09159a2012-11-29 12:51:4829#include "content/public/browser/web_contents.h"
treibe7ccb7e2014-09-09 19:21:4530#include "content/public/browser/web_contents_user_data.h"
[email protected]59f21562013-05-23 16:19:3031#include "content/public/browser/web_ui.h"
[email protected]a09159a2012-11-29 12:51:4832#include "grit/browser_resources.h"
[email protected]a09159a2012-11-29 12:51:4833#include "ui/base/l10n/l10n_util.h"
34#include "ui/base/resource/resource_bundle.h"
[email protected]cd67ed52013-10-15 01:22:1335#include "ui/base/webui/jstemplate_builder.h"
36#include "ui/base/webui/web_ui_util.h"
[email protected]a09159a2012-11-29 12:51:4837
treib9dbb9302015-01-08 14:42:3938#if defined(OS_ANDROID)
39#include "chrome/browser/supervised_user/child_accounts/child_account_feedback_reporter_android.h"
40#else
treibe7ccb7e2014-09-09 19:21:4541#include "chrome/browser/ui/browser_finder.h"
treib5dd8daf32014-12-18 17:36:3742#include "chrome/browser/ui/chrome_pages.h"
treibe7ccb7e2014-09-09 19:21:4543#include "chrome/browser/ui/tabs/tab_strip_model.h"
44#endif
45
[email protected]a09159a2012-11-29 12:51:4846using content::BrowserThread;
treibe7ccb7e2014-09-09 19:21:4547using content::WebContents;
[email protected]a09159a2012-11-29 12:51:4848
[email protected]95c47d02014-08-19 09:17:5049namespace {
50
51static const int kAvatarSize1x = 45;
52static const int kAvatarSize2x = 90;
53
treib885fee12014-08-29 08:07:5854std::string BuildAvatarImageUrl(const std::string& url, int size) {
[email protected]95c47d02014-08-19 09:17:5055 std::string result = url;
56 size_t slash = result.rfind('/');
57 if (slash != std::string::npos)
58 result.insert(slash, "/s" + base::IntToString(size));
treib885fee12014-08-29 08:07:5859 return result;
[email protected]95c47d02014-08-19 09:17:5060}
61
treibe7ccb7e2014-09-09 19:21:4562class TabCloser : public content::WebContentsUserData<TabCloser> {
63 // To use, call TabCloser::CreateForWebContents.
64 private:
65 friend class content::WebContentsUserData<TabCloser>;
66
67 explicit TabCloser(WebContents* web_contents)
68 : web_contents_(web_contents), weak_ptr_factory_(this) {
69 BrowserThread::PostTask(
70 BrowserThread::UI,
71 FROM_HERE,
72 base::Bind(&TabCloser::CloseTabImpl, weak_ptr_factory_.GetWeakPtr()));
73 }
dchengc072fff2014-10-21 11:39:0574 ~TabCloser() override {}
treibe7ccb7e2014-09-09 19:21:4575
76 void CloseTabImpl() {
77 // On Android, FindBrowserWithWebContents and TabStripModel don't exist.
78#if !defined(OS_ANDROID)
79 Browser* browser = chrome::FindBrowserWithWebContents(web_contents_);
80 DCHECK(browser);
81 TabStripModel* tab_strip = browser->tab_strip_model();
82 DCHECK_NE(TabStripModel::kNoTab,
83 tab_strip->GetIndexOfWebContents(web_contents_));
84 if (tab_strip->count() <= 1) {
85 // Don't close the last tab in the window.
86 web_contents_->RemoveUserData(UserDataKey());
87 return;
88 }
89#endif
90 web_contents_->Close();
91 }
92
93 WebContents* web_contents_;
94 base::WeakPtrFactory<TabCloser> weak_ptr_factory_;
95};
96
97} // namespace
98
99DEFINE_WEB_CONTENTS_USER_DATA_KEY(TabCloser);
[email protected]95c47d02014-08-19 09:17:50100
[email protected]b8af2d12014-04-29 07:30:42101// static
[email protected]95c47d02014-08-19 09:17:50102void SupervisedUserInterstitial::Show(
treibe7ccb7e2014-09-09 19:21:45103 WebContents* web_contents,
[email protected]95c47d02014-08-19 09:17:50104 const GURL& url,
treib170c3f82014-12-10 19:13:25105 SupervisedUserURLFilter::FilteringBehaviorReason reason,
[email protected]95c47d02014-08-19 09:17:50106 const base::Callback<void(bool)>& callback) {
[email protected]cce15bb2014-06-17 13:43:51107 SupervisedUserInterstitial* interstitial =
treib170c3f82014-12-10 19:13:25108 new SupervisedUserInterstitial(web_contents, url, reason, callback);
[email protected]b8af2d12014-04-29 07:30:42109
110 // If Init() does not complete fully, immediately delete the interstitial.
111 if (!interstitial->Init())
112 delete interstitial;
113 // Otherwise |interstitial_page_| is responsible for deleting it.
114}
115
[email protected]cce15bb2014-06-17 13:43:51116SupervisedUserInterstitial::SupervisedUserInterstitial(
treibe7ccb7e2014-09-09 19:21:45117 WebContents* web_contents,
[email protected]a09159a2012-11-29 12:51:48118 const GURL& url,
treib170c3f82014-12-10 19:13:25119 SupervisedUserURLFilter::FilteringBehaviorReason reason,
[email protected]a09159a2012-11-29 12:51:48120 const base::Callback<void(bool)>& callback)
121 : web_contents_(web_contents),
treibab0a39e2014-09-24 14:48:28122 profile_(Profile::FromBrowserContext(web_contents->GetBrowserContext())),
[email protected]61f5da22013-09-05 15:52:10123 interstitial_page_(NULL),
[email protected]a09159a2012-11-29 12:51:48124 url_(url),
treib170c3f82014-12-10 19:13:25125 reason_(reason),
bauerb646019b12014-10-16 16:23:09126 callback_(callback),
127 weak_ptr_factory_(this) {}
[email protected]b8af2d12014-04-29 07:30:42128
treibab0a39e2014-09-24 14:48:28129SupervisedUserInterstitial::~SupervisedUserInterstitial() {
130 DCHECK(!web_contents_);
131}
[email protected]b8af2d12014-04-29 07:30:42132
[email protected]cce15bb2014-06-17 13:43:51133bool SupervisedUserInterstitial::Init() {
[email protected]61f5da22013-09-05 15:52:10134 if (ShouldProceed()) {
135 // It can happen that the site was only allowed very recently and the URL
136 // filter on the IO thread had not been updated yet. Proceed with the
137 // request without showing the interstitial.
138 DispatchContinueRequest(true);
[email protected]b8af2d12014-04-29 07:30:42139 return false;
[email protected]61f5da22013-09-05 15:52:10140 }
141
[email protected]b8af2d12014-04-29 07:30:42142 InfoBarService* service = InfoBarService::FromWebContents(web_contents_);
[email protected]93c23212013-09-19 14:22:38143 if (service) {
[email protected]b8af2d12014-04-29 07:30:42144 // Remove all the infobars which are attached to |web_contents_| and for
[email protected]93c23212013-09-19 14:22:38145 // which ShouldExpire() returns true.
146 content::LoadCommittedDetails details;
147 // |details.is_in_page| is default false, and |details.is_main_frame| is
148 // default true. This results in is_navigation_to_different_page() returning
149 // true.
150 DCHECK(details.is_navigation_to_different_page());
151 const content::NavigationController& controller =
[email protected]b8af2d12014-04-29 07:30:42152 web_contents_->GetController();
[email protected]93c23212013-09-19 14:22:38153 details.entry = controller.GetActiveEntry();
154 if (controller.GetLastCommittedEntry()) {
155 details.previous_entry_index = controller.GetLastCommittedEntryIndex();
156 details.previous_url = controller.GetLastCommittedEntry()->GetURL();
157 }
158 details.type = content::NAVIGATION_TYPE_NEW_PAGE;
[email protected]b44f1d32014-04-10 13:53:26159 for (int i = service->infobar_count() - 1; i >= 0; --i) {
[email protected]051655ad2014-04-18 15:09:41160 infobars::InfoBar* infobar = service->infobar_at(i);
[email protected]5daf1d92014-04-04 15:52:13161 if (infobar->delegate()->ShouldExpire(
162 InfoBarService::NavigationDetailsFromLoadCommittedDetails(
163 details)))
[email protected]b44f1d32014-04-10 13:53:26164 service->RemoveInfoBar(infobar);
[email protected]93c23212013-09-19 14:22:38165 }
166 }
167
treibab0a39e2014-09-24 14:48:28168 SupervisedUserService* supervised_user_service =
169 SupervisedUserServiceFactory::GetForProfile(profile_);
170 supervised_user_service->AddObserver(this);
[email protected]a09159a2012-11-29 12:51:48171
[email protected]0369d6ab2013-08-09 01:52:59172 interstitial_page_ =
[email protected]b8af2d12014-04-29 07:30:42173 content::InterstitialPage::Create(web_contents_, true, url_, this);
[email protected]a09159a2012-11-29 12:51:48174 interstitial_page_->Show();
[email protected]a09159a2012-11-29 12:51:48175
[email protected]b8af2d12014-04-29 07:30:42176 return true;
177}
[email protected]a09159a2012-11-29 12:51:48178
[email protected]cce15bb2014-06-17 13:43:51179std::string SupervisedUserInterstitial::GetHTMLContents() {
[email protected]cb1078de2013-12-23 20:04:22180 base::DictionaryValue strings;
[email protected]a09159a2012-11-29 12:51:48181 strings.SetString("blockPageTitle",
182 l10n_util::GetStringUTF16(IDS_BLOCK_INTERSTITIAL_TITLE));
[email protected]fae057a2013-06-21 22:46:08183
[email protected]cce15bb2014-06-17 13:43:51184 SupervisedUserService* supervised_user_service =
treibab0a39e2014-09-24 14:48:28185 SupervisedUserServiceFactory::GetForProfile(profile_);
[email protected]0369d6ab2013-08-09 01:52:59186
[email protected]cce15bb2014-06-17 13:43:51187 bool allow_access_requests = supervised_user_service->AccessRequestsEnabled();
[email protected]0369d6ab2013-08-09 01:52:59188 strings.SetBoolean("allowAccessRequests", allow_access_requests);
189
treibab0a39e2014-09-24 14:48:28190 std::string profile_image_url = profile_->GetPrefs()->GetString(
[email protected]95c47d02014-08-19 09:17:50191 prefs::kSupervisedUserCustodianProfileImageURL);
192 strings.SetString("avatarURL1x", BuildAvatarImageUrl(profile_image_url,
[email protected]95c47d02014-08-19 09:17:50193 kAvatarSize1x));
194 strings.SetString("avatarURL2x", BuildAvatarImageUrl(profile_image_url,
[email protected]95c47d02014-08-19 09:17:50195 kAvatarSize2x));
196
treibab0a39e2014-09-24 14:48:28197 std::string profile_image_url2 = profile_->GetPrefs()->GetString(
[email protected]95c47d02014-08-19 09:17:50198 prefs::kSupervisedUserSecondCustodianProfileImageURL);
199 strings.SetString("secondAvatarURL1x", BuildAvatarImageUrl(profile_image_url2,
[email protected]95c47d02014-08-19 09:17:50200 kAvatarSize1x));
201 strings.SetString("secondAvatarURL2x", BuildAvatarImageUrl(profile_image_url2,
[email protected]95c47d02014-08-19 09:17:50202 kAvatarSize2x));
203
treibad86c012014-12-09 11:12:55204 bool is_child_account = profile_->IsChild();
treib5fc1aed2014-12-08 12:46:03205
[email protected]0085863a2013-12-06 21:19:03206 base::string16 custodian =
[email protected]cce15bb2014-06-17 13:43:51207 base::UTF8ToUTF16(supervised_user_service->GetCustodianName());
treib5fc1aed2014-12-08 12:46:03208 base::string16 second_custodian =
209 base::UTF8ToUTF16(supervised_user_service->GetSecondCustodianName());
210
211 base::string16 block_message;
212 if (allow_access_requests) {
213 if (is_child_account) {
214 block_message = l10n_util::GetStringUTF16(
215 second_custodian.empty()
216 ? IDS_CHILD_BLOCK_INTERSTITIAL_MESSAGE_SINGLE_PARENT
217 : IDS_CHILD_BLOCK_INTERSTITIAL_MESSAGE_MULTI_PARENT);
218 } else {
219 block_message = l10n_util::GetStringFUTF16(
220 IDS_BLOCK_INTERSTITIAL_MESSAGE, custodian);
221 }
222 } else {
223 block_message = l10n_util::GetStringUTF16(
224 IDS_BLOCK_INTERSTITIAL_MESSAGE_ACCESS_REQUESTS_DISABLED);
225 }
226 strings.SetString("blockPageMessage", block_message);
treib170c3f82014-12-10 19:13:25227 strings.SetString("blockReasonMessage", is_child_account
228 ? l10n_util::GetStringUTF16(
treibd733ef8b2015-01-21 19:56:32229 SupervisedUserURLFilter::GetBlockMessageID(reason_))
treib170c3f82014-12-10 19:13:25230 : base::string16());
[email protected]fae057a2013-06-21 22:46:08231
treib5dd8daf32014-12-18 17:36:37232 bool show_feedback = false;
treib9dbb9302015-01-08 14:42:39233#if defined(GOOGLE_CHROME_BUILD)
treib5dd8daf32014-12-18 17:36:37234 show_feedback = is_child_account &&
235 SupervisedUserURLFilter::ReasonIsAutomatic(reason_);
236#endif
237 strings.SetBoolean("showFeedbackLink", show_feedback);
238 strings.SetString("feedbackLink",
239 l10n_util::GetStringUTF16(IDS_BLOCK_INTERSTITIAL_SEND_FEEDBACK));
240
[email protected]a09159a2012-11-29 12:51:48241 strings.SetString("backButton", l10n_util::GetStringUTF16(IDS_BACK_BUTTON));
treib5fc1aed2014-12-08 12:46:03242 strings.SetString("requestAccessButton", l10n_util::GetStringUTF16(
243 is_child_account
244 ? IDS_CHILD_BLOCK_INTERSTITIAL_REQUEST_ACCESS_BUTTON
245 : IDS_BLOCK_INTERSTITIAL_REQUEST_ACCESS_BUTTON));
[email protected]59f21562013-05-23 16:19:30246
treib5fc1aed2014-12-08 12:46:03247 base::string16 request_sent_message;
khannansf3b27192015-01-09 17:28:17248 base::string16 request_failed_message;
treib5fc1aed2014-12-08 12:46:03249 if (is_child_account) {
khannansf3b27192015-01-09 17:28:17250 if (second_custodian.empty()) {
251 request_sent_message = l10n_util::GetStringUTF16(
252 IDS_CHILD_BLOCK_INTERSTITIAL_REQUEST_SENT_MESSAGE_SINGLE_PARENT);
253 request_failed_message = l10n_util::GetStringUTF16(
254 IDS_CHILD_BLOCK_INTERSTITIAL_REQUEST_FAILED_MESSAGE_SINGLE_PARENT);
255 } else {
256 request_sent_message = l10n_util::GetStringUTF16(
257 IDS_CHILD_BLOCK_INTERSTITIAL_REQUEST_SENT_MESSAGE_MULTI_PARENT);
258 request_failed_message = l10n_util::GetStringUTF16(
259 IDS_CHILD_BLOCK_INTERSTITIAL_REQUEST_FAILED_MESSAGE_MULTI_PARENT);
260 }
treib5fc1aed2014-12-08 12:46:03261 } else {
262 request_sent_message = l10n_util::GetStringFUTF16(
263 IDS_BLOCK_INTERSTITIAL_REQUEST_SENT_MESSAGE, custodian);
khannansf3b27192015-01-09 17:28:17264 request_failed_message = l10n_util::GetStringFUTF16(
265 IDS_BLOCK_INTERSTITIAL_REQUEST_FAILED_MESSAGE, custodian);
treib5fc1aed2014-12-08 12:46:03266 }
267 strings.SetString("requestSentMessage", request_sent_message);
khannansf3b27192015-01-09 17:28:17268 strings.SetString("requestFailedMessage", request_failed_message);
[email protected]59f21562013-05-23 16:19:30269
[email protected]5053d402013-01-23 05:19:26270 webui::SetFontAndTextDirection(&strings);
[email protected]a09159a2012-11-29 12:51:48271
bauerbd0399182015-01-26 10:20:45272 std::string html =
273 ResourceBundle::GetSharedInstance()
274 .GetRawDataResource(IDR_SUPERVISED_USER_BLOCK_INTERSTITIAL_HTML)
275 .as_string();
276 webui::AppendWebUiCssTextDefaults(&html);
[email protected]a09159a2012-11-29 12:51:48277
[email protected]2779e3a2013-01-22 18:40:21278 return webui::GetI18nTemplateHtml(html, &strings);
[email protected]a09159a2012-11-29 12:51:48279}
280
[email protected]cce15bb2014-06-17 13:43:51281void SupervisedUserInterstitial::CommandReceived(const std::string& command) {
[email protected]2c145422013-01-24 18:15:40282 // For use in histograms.
283 enum Commands {
284 PREVIEW,
285 BACK,
286 NTP,
[email protected]59f21562013-05-23 16:19:30287 ACCESS_REQUEST,
[email protected]2c145422013-01-24 18:15:40288 HISTOGRAM_BOUNDING_VALUE
289 };
290
[email protected]a09159a2012-11-29 12:51:48291 if (command == "\"back\"") {
[email protected]2c145422013-01-24 18:15:40292 UMA_HISTOGRAM_ENUMERATION("ManagedMode.BlockingInterstitialCommand",
293 BACK,
294 HISTOGRAM_BOUNDING_VALUE);
treibe7ccb7e2014-09-09 19:21:45295
296 // Close the tab if there is no history entry to go back to.
297 DCHECK(web_contents_->GetController().GetTransientEntry());
298 if (web_contents_->GetController().GetEntryCount() == 1)
299 TabCloser::CreateForWebContents(web_contents_);
300
[email protected]a09159a2012-11-29 12:51:48301 interstitial_page_->DontProceed();
302 return;
303 }
304
[email protected]59f21562013-05-23 16:19:30305 if (command == "\"request\"") {
[email protected]2c145422013-01-24 18:15:40306 UMA_HISTOGRAM_ENUMERATION("ManagedMode.BlockingInterstitialCommand",
[email protected]59f21562013-05-23 16:19:30307 ACCESS_REQUEST,
[email protected]2c145422013-01-24 18:15:40308 HISTOGRAM_BOUNDING_VALUE);
[email protected]ad7a89e2013-05-31 12:03:24309
[email protected]cce15bb2014-06-17 13:43:51310 SupervisedUserService* supervised_user_service =
treibab0a39e2014-09-24 14:48:28311 SupervisedUserServiceFactory::GetForProfile(profile_);
bauerb646019b12014-10-16 16:23:09312 supervised_user_service->AddAccessRequest(
313 url_, base::Bind(&SupervisedUserInterstitial::OnAccessRequestAdded,
314 weak_ptr_factory_.GetWeakPtr()));
[email protected]a09159a2012-11-29 12:51:48315 return;
316 }
317
treib5dd8daf32014-12-18 17:36:37318 if (command == "\"feedback\"") {
treibd733ef8b2015-01-21 19:56:32319 base::string16 reason = l10n_util::GetStringUTF16(
320 SupervisedUserURLFilter::GetBlockMessageID(reason_));
321 std::string message = l10n_util::GetStringFUTF8(
322 IDS_BLOCK_INTERSTITIAL_DEFAULT_FEEDBACK_TEXT, reason);
treib9dbb9302015-01-08 14:42:39323#if defined(OS_ANDROID)
treibd733ef8b2015-01-21 19:56:32324 ReportChildAccountFeedback(web_contents_, message, url_);
treib9dbb9302015-01-08 14:42:39325#else
treib5dd8daf32014-12-18 17:36:37326 std::string bucket;
327#if defined(OS_CHROMEOS)
328 bucket = "UnicornCrOS";
329#else
330 bucket = "UnicornDesktop";
331#endif
332 chrome::ShowFeedbackPage(
333 chrome::FindBrowserWithWebContents(web_contents_),
treibd733ef8b2015-01-21 19:56:32334 message,
treib5dd8daf32014-12-18 17:36:37335 bucket);
treib9dbb9302015-01-08 14:42:39336#endif
treib5dd8daf32014-12-18 17:36:37337 return;
338 }
treib5dd8daf32014-12-18 17:36:37339
[email protected]a09159a2012-11-29 12:51:48340 NOTREACHED();
341}
342
[email protected]cce15bb2014-06-17 13:43:51343void SupervisedUserInterstitial::OnProceed() {
[email protected]61f5da22013-09-05 15:52:10344 DispatchContinueRequest(true);
345}
[email protected]a09159a2012-11-29 12:51:48346
[email protected]cce15bb2014-06-17 13:43:51347void SupervisedUserInterstitial::OnDontProceed() {
[email protected]6c7af96d2013-03-28 22:55:14348 DispatchContinueRequest(false);
[email protected]a09159a2012-11-29 12:51:48349}
350
treibab0a39e2014-09-24 14:48:28351void SupervisedUserInterstitial::OnURLFilterChanged() {
352 if (ShouldProceed())
353 interstitial_page_->Proceed();
354}
355
bauerb646019b12014-10-16 16:23:09356void SupervisedUserInterstitial::OnAccessRequestAdded(bool success) {
bauerbfc4af2ac2014-11-07 14:27:05357 VLOG(1) << "Sent access request for " << url_.spec()
358 << (success ? " successfully" : " unsuccessfully");
khannansf3b27192015-01-09 17:28:17359 std::string jsFunc =
360 base::StringPrintf("setRequestStatus(%s);", success ? "true" : "false");
361 interstitial_page_->GetMainFrame()->ExecuteJavaScript(
362 base::ASCIIToUTF16(jsFunc));
bauerb646019b12014-10-16 16:23:09363}
364
[email protected]cce15bb2014-06-17 13:43:51365bool SupervisedUserInterstitial::ShouldProceed() {
[email protected]cce15bb2014-06-17 13:43:51366 SupervisedUserService* supervised_user_service =
treibab0a39e2014-09-24 14:48:28367 SupervisedUserServiceFactory::GetForProfile(profile_);
[email protected]cce15bb2014-06-17 13:43:51368 SupervisedUserURLFilter* url_filter =
369 supervised_user_service->GetURLFilterForUIThread();
treib9e4fab902014-10-29 14:25:26370 SupervisedUserURLFilter::FilteringBehavior behavior;
treib22c3a042015-01-15 21:30:13371 if (url_filter->HasAsyncURLChecker()) {
372 if (!url_filter->GetManualFilteringBehaviorForURL(url_, &behavior))
373 return false;
374 } else {
375 behavior = url_filter->GetFilteringBehaviorForURL(url_);
376 }
377 return behavior != SupervisedUserURLFilter::BLOCK;
[email protected]61f5da22013-09-05 15:52:10378}
379
[email protected]cce15bb2014-06-17 13:43:51380void SupervisedUserInterstitial::DispatchContinueRequest(
381 bool continue_request) {
treibab0a39e2014-09-24 14:48:28382 SupervisedUserService* supervised_user_service =
383 SupervisedUserServiceFactory::GetForProfile(profile_);
384 supervised_user_service->RemoveObserver(this);
385
[email protected]0369d6ab2013-08-09 01:52:59386 BrowserThread::PostTask(
387 BrowserThread::IO, FROM_HERE, base::Bind(callback_, continue_request));
treibab0a39e2014-09-24 14:48:28388
389 // After this, the WebContents may be destroyed. Make sure we don't try to use
390 // it again.
391 web_contents_ = NULL;
[email protected]6c7af96d2013-03-28 22:55:14392}