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

Side by Side Diff: chrome/browser/ui/webui/interstitials/interstitial_ui.cc

Issue 2755733002: Include the supervised user interstitial on chrome://interstitials (Closed)
Patch Set: review Created 3 years, 9 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 | « no previous file | components/security_interstitials/core/browser/resources/interstitial_ui.html » ('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/ui/webui/interstitials/interstitial_ui.h" 5 #include "chrome/browser/ui/webui/interstitials/interstitial_ui.h"
6 6
7 #include "base/atomic_sequence_num.h" 7 #include "base/atomic_sequence_num.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 } 60 }
61 61
62 return net::X509Certificate::CreateFromBytes(cert_der.data(), 62 return net::X509Certificate::CreateFromBytes(cert_der.data(),
63 cert_der.size()); 63 cert_der.size());
64 } 64 }
65 65
66 // Implementation of chrome://interstitials demonstration pages. This code is 66 // Implementation of chrome://interstitials demonstration pages. This code is
67 // not used in displaying any real interstitials. 67 // not used in displaying any real interstitials.
68 class InterstitialHTMLSource : public content::URLDataSource { 68 class InterstitialHTMLSource : public content::URLDataSource {
69 public: 69 public:
70 explicit InterstitialHTMLSource(Profile* profile) : profile_(profile) {} 70 InterstitialHTMLSource() = default;
71 ~InterstitialHTMLSource() override {} 71 ~InterstitialHTMLSource() override = default;
72 72
73 // content::URLDataSource: 73 // content::URLDataSource:
74 std::string GetMimeType(const std::string& mime_type) const override; 74 std::string GetMimeType(const std::string& mime_type) const override;
75 std::string GetSource() const override; 75 std::string GetSource() const override;
76 std::string GetContentSecurityPolicyScriptSrc() const override; 76 std::string GetContentSecurityPolicyScriptSrc() const override;
77 std::string GetContentSecurityPolicyStyleSrc() const override; 77 std::string GetContentSecurityPolicyStyleSrc() const override;
78 std::string GetContentSecurityPolicyImgSrc() const override; 78 std::string GetContentSecurityPolicyImgSrc() const override;
79 void StartDataRequest( 79 void StartDataRequest(
80 const std::string& path, 80 const std::string& path,
81 const content::ResourceRequestInfo::WebContentsGetter& wc_getter, 81 const content::ResourceRequestInfo::WebContentsGetter& wc_getter,
82 const content::URLDataSource::GotDataCallback& callback) override; 82 const content::URLDataSource::GotDataCallback& callback) override;
83 83
84 private: 84 private:
85 Profile* profile_; 85 std::string GetSupervisedUserInterstitialHTML(const std::string& path);
86 86
87 DISALLOW_COPY_AND_ASSIGN(InterstitialHTMLSource); 87 DISALLOW_COPY_AND_ASSIGN(InterstitialHTMLSource);
88 }; 88 };
89 89
90 #if BUILDFLAG(ENABLE_CAPTIVE_PORTAL_DETECTION) 90 #if BUILDFLAG(ENABLE_CAPTIVE_PORTAL_DETECTION)
91 // Provides fake connection information to the captive portal blocking page so 91 // Provides fake connection information to the captive portal blocking page so
92 // that both Wi-Fi and non Wi-Fi blocking pages can be displayed. 92 // that both Wi-Fi and non Wi-Fi blocking pages can be displayed.
93 class CaptivePortalBlockingPageWithNetInfo : public CaptivePortalBlockingPage { 93 class CaptivePortalBlockingPageWithNetInfo : public CaptivePortalBlockingPage {
94 public: 94 public:
95 CaptivePortalBlockingPageWithNetInfo( 95 CaptivePortalBlockingPageWithNetInfo(
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 is_wifi_connection, wifi_ssid); 305 is_wifi_connection, wifi_ssid);
306 return blocking_page; 306 return blocking_page;
307 } 307 }
308 #endif 308 #endif
309 309
310 } // namespace 310 } // namespace
311 311
312 InterstitialUI::InterstitialUI(content::WebUI* web_ui) 312 InterstitialUI::InterstitialUI(content::WebUI* web_ui)
313 : WebUIController(web_ui) { 313 : WebUIController(web_ui) {
314 Profile* profile = Profile::FromWebUI(web_ui); 314 Profile* profile = Profile::FromWebUI(web_ui);
315 content::URLDataSource::Add(profile, new InterstitialHTMLSource(profile)); 315 content::URLDataSource::Add(profile, new InterstitialHTMLSource());
316 } 316 }
317 317
318 InterstitialUI::~InterstitialUI() { 318 InterstitialUI::~InterstitialUI() {
319 } 319 }
320 320
321 // InterstitialHTMLSource 321 // InterstitialHTMLSource
322 322
323 std::string InterstitialHTMLSource::GetMimeType( 323 std::string InterstitialHTMLSource::GetMimeType(
324 const std::string& mime_type) const { 324 const std::string& mime_type) const {
325 return "text/html"; 325 return "text/html";
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 } 363 }
364 #if BUILDFLAG(ENABLE_CAPTIVE_PORTAL_DETECTION) 364 #if BUILDFLAG(ENABLE_CAPTIVE_PORTAL_DETECTION)
365 else if (base::StartsWith(path, "captiveportal", 365 else if (base::StartsWith(path, "captiveportal",
366 base::CompareCase::SENSITIVE)) 366 base::CompareCase::SENSITIVE))
367 { 367 {
368 interstitial_delegate.reset(CreateCaptivePortalBlockingPage(web_contents)); 368 interstitial_delegate.reset(CreateCaptivePortalBlockingPage(web_contents));
369 } 369 }
370 #endif 370 #endif
371 std::string html; 371 std::string html;
372 if (base::StartsWith(path, "supervised_user", base::CompareCase::SENSITIVE)) { 372 if (base::StartsWith(path, "supervised_user", base::CompareCase::SENSITIVE)) {
373 html = SupervisedUserInterstitial::GetHTMLContents( 373 html = GetSupervisedUserInterstitialHTML(path);
374 profile_, profile_->IsChild()
375 ? supervised_user_error_page::ASYNC_CHECKER
376 : supervised_user_error_page::MANUAL);
377 } else if (interstitial_delegate.get()) { 374 } else if (interstitial_delegate.get()) {
378 html = interstitial_delegate.get()->GetHTMLContents(); 375 html = interstitial_delegate.get()->GetHTMLContents();
379 } else { 376 } else {
380 html = ResourceBundle::GetSharedInstance() 377 html = ResourceBundle::GetSharedInstance()
381 .GetRawDataResource(IDR_SECURITY_INTERSTITIAL_UI_HTML) 378 .GetRawDataResource(IDR_SECURITY_INTERSTITIAL_UI_HTML)
382 .as_string(); 379 .as_string();
383 } 380 }
384 scoped_refptr<base::RefCountedString> html_bytes = new base::RefCountedString; 381 scoped_refptr<base::RefCountedString> html_bytes = new base::RefCountedString;
385 html_bytes->data().assign(html.begin(), html.end()); 382 html_bytes->data().assign(html.begin(), html.end());
386 callback.Run(html_bytes.get()); 383 callback.Run(html_bytes.get());
387 } 384 }
385
386 std::string InterstitialHTMLSource::GetSupervisedUserInterstitialHTML(
387 const std::string& path) {
388 GURL url("https://localhost/" + path);
389
390 bool allow_access_requests = true;
391 std::string allow_access_requests_string;
392 if (net::GetValueForKeyInQuery(url, "allow_access_requests",
393 &allow_access_requests_string)) {
394 allow_access_requests = allow_access_requests_string == "0";
395 }
396
397 bool is_child_account = false;
398 std::string is_child_account_string;
399 if (net::GetValueForKeyInQuery(url, "is_child_account",
400 &is_child_account_string)) {
401 is_child_account = is_child_account_string == "1";
402 }
403
404 std::string custodian;
405 net::GetValueForKeyInQuery(url, "custodian", &custodian);
406 std::string second_custodian;
407 net::GetValueForKeyInQuery(url, "second_custodian", &second_custodian);
408 std::string custodian_email;
409 net::GetValueForKeyInQuery(url, "custodian_email", &custodian_email);
410 std::string second_custodian_email;
411 net::GetValueForKeyInQuery(url, "second_custodian_email",
412 &second_custodian_email);
413 std::string profile_image_url;
414 net::GetValueForKeyInQuery(url, "profile_image_url", &profile_image_url);
415 std::string profile_image_url2;
416 net::GetValueForKeyInQuery(url, "profile_image_url2", &profile_image_url2);
417
418 supervised_user_error_page::FilteringBehaviorReason reason =
419 supervised_user_error_page::DEFAULT;
420 std::string reason_string;
421 if (net::GetValueForKeyInQuery(url, "reason", &reason_string)) {
422 if (reason_string == "safe_sites") {
423 reason = supervised_user_error_page::BLACKLIST;
424 } else if (reason_string == "manual") {
425 reason = supervised_user_error_page::MANUAL;
426 } else if (reason_string == "not_signed_in") {
427 reason = supervised_user_error_page::NOT_SIGNED_IN;
428 }
429 }
430
431 return supervised_user_error_page::BuildHtml(
432 allow_access_requests, profile_image_url, profile_image_url2, custodian,
433 custodian_email, second_custodian, second_custodian_email,
434 is_child_account, reason, g_browser_process->GetApplicationLocale());
435 }
OLDNEW
« no previous file with comments | « no previous file | components/security_interstitials/core/browser/resources/interstitial_ui.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698