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

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

Issue 789703004: Reflect the status of a request for accessing a blacklisted url. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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
« no previous file with comments | « chrome/browser/ssl/ssl_browser_tests.cc ('k') | chrome/browser/ui/browser_focus_uitest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_interstitial.h" 5 #include "chrome/browser/supervised_user/supervised_user_interstitial.h"
6 6
7 #include "base/memory/weak_ptr.h" 7 #include "base/memory/weak_ptr.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
11 #include "base/strings/stringprintf.h"
11 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
12 #include "base/values.h" 13 #include "base/values.h"
13 #include "chrome/browser/infobars/infobar_service.h" 14 #include "chrome/browser/infobars/infobar_service.h"
14 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/supervised_user/supervised_user_service.h" 16 #include "chrome/browser/supervised_user/supervised_user_service.h"
16 #include "chrome/browser/supervised_user/supervised_user_service_factory.h" 17 #include "chrome/browser/supervised_user/supervised_user_service_factory.h"
17 #include "chrome/common/pref_names.h" 18 #include "chrome/common/pref_names.h"
18 #include "chrome/grit/generated_resources.h" 19 #include "chrome/grit/generated_resources.h"
19 #include "components/infobars/core/infobar.h" 20 #include "components/infobars/core/infobar.h"
20 #include "components/infobars/core/infobar_delegate.h" 21 #include "components/infobars/core/infobar_delegate.h"
21 #include "content/public/browser/browser_thread.h" 22 #include "content/public/browser/browser_thread.h"
22 #include "content/public/browser/interstitial_page.h" 23 #include "content/public/browser/interstitial_page.h"
23 #include "content/public/browser/navigation_controller.h" 24 #include "content/public/browser/navigation_controller.h"
24 #include "content/public/browser/navigation_details.h" 25 #include "content/public/browser/navigation_details.h"
25 #include "content/public/browser/navigation_entry.h" 26 #include "content/public/browser/navigation_entry.h"
27 #include "content/public/browser/render_frame_host.h"
28 #include "content/public/browser/render_view_host.h"
26 #include "content/public/browser/web_contents.h" 29 #include "content/public/browser/web_contents.h"
27 #include "content/public/browser/web_contents_user_data.h" 30 #include "content/public/browser/web_contents_user_data.h"
28 #include "content/public/browser/web_ui.h" 31 #include "content/public/browser/web_ui.h"
29 #include "grit/browser_resources.h" 32 #include "grit/browser_resources.h"
30 #include "ui/base/l10n/l10n_util.h" 33 #include "ui/base/l10n/l10n_util.h"
31 #include "ui/base/resource/resource_bundle.h" 34 #include "ui/base/resource/resource_bundle.h"
32 #include "ui/base/webui/jstemplate_builder.h" 35 #include "ui/base/webui/jstemplate_builder.h"
33 #include "ui/base/webui/web_ui_util.h" 36 #include "ui/base/webui/web_ui_util.h"
34 37
35 #if defined(OS_ANDROID) 38 #if defined(OS_ANDROID)
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 strings.SetString("feedbackLink", 238 strings.SetString("feedbackLink",
236 l10n_util::GetStringUTF16(IDS_BLOCK_INTERSTITIAL_SEND_FEEDBACK)); 239 l10n_util::GetStringUTF16(IDS_BLOCK_INTERSTITIAL_SEND_FEEDBACK));
237 240
238 strings.SetString("backButton", l10n_util::GetStringUTF16(IDS_BACK_BUTTON)); 241 strings.SetString("backButton", l10n_util::GetStringUTF16(IDS_BACK_BUTTON));
239 strings.SetString("requestAccessButton", l10n_util::GetStringUTF16( 242 strings.SetString("requestAccessButton", l10n_util::GetStringUTF16(
240 is_child_account 243 is_child_account
241 ? IDS_CHILD_BLOCK_INTERSTITIAL_REQUEST_ACCESS_BUTTON 244 ? IDS_CHILD_BLOCK_INTERSTITIAL_REQUEST_ACCESS_BUTTON
242 : IDS_BLOCK_INTERSTITIAL_REQUEST_ACCESS_BUTTON)); 245 : IDS_BLOCK_INTERSTITIAL_REQUEST_ACCESS_BUTTON));
243 246
244 base::string16 request_sent_message; 247 base::string16 request_sent_message;
248 base::string16 request_failed_message;
245 if (is_child_account) { 249 if (is_child_account) {
246 request_sent_message = l10n_util::GetStringUTF16( 250 if (second_custodian.empty()) {
247 second_custodian.empty() 251 request_sent_message = l10n_util::GetStringUTF16(
248 ? IDS_CHILD_BLOCK_INTERSTITIAL_REQUEST_SENT_MESSAGE_SINGLE_PARENT 252 IDS_CHILD_BLOCK_INTERSTITIAL_REQUEST_SENT_MESSAGE_SINGLE_PARENT);
249 : IDS_CHILD_BLOCK_INTERSTITIAL_REQUEST_SENT_MESSAGE_MULTI_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 }
250 } else { 261 } else {
251 request_sent_message = l10n_util::GetStringFUTF16( 262 request_sent_message = l10n_util::GetStringFUTF16(
252 IDS_BLOCK_INTERSTITIAL_REQUEST_SENT_MESSAGE, custodian); 263 IDS_BLOCK_INTERSTITIAL_REQUEST_SENT_MESSAGE, custodian);
264 request_failed_message = l10n_util::GetStringFUTF16(
265 IDS_BLOCK_INTERSTITIAL_REQUEST_FAILED_MESSAGE, custodian);
253 } 266 }
254 strings.SetString("requestSentMessage", request_sent_message); 267 strings.SetString("requestSentMessage", request_sent_message);
268 strings.SetString("requestFailedMessage", request_failed_message);
255 269
256 webui::SetFontAndTextDirection(&strings); 270 webui::SetFontAndTextDirection(&strings);
257 271
258 base::StringPiece html(ResourceBundle::GetSharedInstance().GetRawDataResource( 272 base::StringPiece html(ResourceBundle::GetSharedInstance().GetRawDataResource(
259 IDR_SUPERVISED_USER_BLOCK_INTERSTITIAL_HTML)); 273 IDR_SUPERVISED_USER_BLOCK_INTERSTITIAL_HTML));
260 274
261 return webui::GetI18nTemplateHtml(html, &strings); 275 return webui::GetI18nTemplateHtml(html, &strings);
262 } 276 }
263 277
264 void SupervisedUserInterstitial::CommandReceived(const std::string& command) { 278 void SupervisedUserInterstitial::CommandReceived(const std::string& command) {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 void SupervisedUserInterstitial::OnDontProceed() { 340 void SupervisedUserInterstitial::OnDontProceed() {
327 DispatchContinueRequest(false); 341 DispatchContinueRequest(false);
328 } 342 }
329 343
330 void SupervisedUserInterstitial::OnURLFilterChanged() { 344 void SupervisedUserInterstitial::OnURLFilterChanged() {
331 if (ShouldProceed()) 345 if (ShouldProceed())
332 interstitial_page_->Proceed(); 346 interstitial_page_->Proceed();
333 } 347 }
334 348
335 void SupervisedUserInterstitial::OnAccessRequestAdded(bool success) { 349 void SupervisedUserInterstitial::OnAccessRequestAdded(bool success) {
336 // TODO(akuegel): Figure out how to show the result of issuing the permission
337 // request in the UI. Currently, we assume the permission request was created
338 // successfully.
339 VLOG(1) << "Sent access request for " << url_.spec() 350 VLOG(1) << "Sent access request for " << url_.spec()
340 << (success ? " successfully" : " unsuccessfully"); 351 << (success ? " successfully" : " unsuccessfully");
352 std::string jsFunc =
353 base::StringPrintf("setRequestStatus(%s);", success ? "true" : "false");
354 interstitial_page_->GetMainFrame()->ExecuteJavaScript(
355 base::ASCIIToUTF16(jsFunc));
341 } 356 }
342 357
343 bool SupervisedUserInterstitial::ShouldProceed() { 358 bool SupervisedUserInterstitial::ShouldProceed() {
344 SupervisedUserService* supervised_user_service = 359 SupervisedUserService* supervised_user_service =
345 SupervisedUserServiceFactory::GetForProfile(profile_); 360 SupervisedUserServiceFactory::GetForProfile(profile_);
346 SupervisedUserURLFilter* url_filter = 361 SupervisedUserURLFilter* url_filter =
347 supervised_user_service->GetURLFilterForUIThread(); 362 supervised_user_service->GetURLFilterForUIThread();
348 SupervisedUserURLFilter::FilteringBehavior behavior; 363 SupervisedUserURLFilter::FilteringBehavior behavior;
349 return (url_filter->GetManualFilteringBehaviorForURL(url_, &behavior) && 364 return (url_filter->GetManualFilteringBehaviorForURL(url_, &behavior) &&
350 behavior != SupervisedUserURLFilter::BLOCK); 365 behavior != SupervisedUserURLFilter::BLOCK);
351 } 366 }
352 367
353 void SupervisedUserInterstitial::DispatchContinueRequest( 368 void SupervisedUserInterstitial::DispatchContinueRequest(
354 bool continue_request) { 369 bool continue_request) {
355 SupervisedUserService* supervised_user_service = 370 SupervisedUserService* supervised_user_service =
356 SupervisedUserServiceFactory::GetForProfile(profile_); 371 SupervisedUserServiceFactory::GetForProfile(profile_);
357 supervised_user_service->RemoveObserver(this); 372 supervised_user_service->RemoveObserver(this);
358 373
359 BrowserThread::PostTask( 374 BrowserThread::PostTask(
360 BrowserThread::IO, FROM_HERE, base::Bind(callback_, continue_request)); 375 BrowserThread::IO, FROM_HERE, base::Bind(callback_, continue_request));
361 376
362 // After this, the WebContents may be destroyed. Make sure we don't try to use 377 // After this, the WebContents may be destroyed. Make sure we don't try to use
363 // it again. 378 // it again.
364 web_contents_ = NULL; 379 web_contents_ = NULL;
365 } 380 }
OLDNEW
« no previous file with comments | « chrome/browser/ssl/ssl_browser_tests.cc ('k') | chrome/browser/ui/browser_focus_uitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698