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/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" |
11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h" | 13 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h" |
14 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 14 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
15 #include "chrome/browser/safe_browsing/ui_manager.h" | 15 #include "chrome/browser/safe_browsing/ui_manager.h" |
16 #include "chrome/browser/ssl/bad_clock_blocking_page.h" | 16 #include "chrome/browser/ssl/bad_clock_blocking_page.h" |
17 #include "chrome/browser/ssl/ssl_blocking_page.h" | 17 #include "chrome/browser/ssl/ssl_blocking_page.h" |
| 18 #include "chrome/browser/supervised_user/supervised_user_interstitial.h" |
18 #include "chrome/common/features.h" | 19 #include "chrome/common/features.h" |
19 #include "chrome/common/url_constants.h" | 20 #include "chrome/common/url_constants.h" |
20 #include "components/grit/components_resources.h" | 21 #include "components/grit/components_resources.h" |
21 #include "components/security_interstitials/core/ssl_error_ui.h" | 22 #include "components/security_interstitials/core/ssl_error_ui.h" |
| 23 #include "components/supervised_user_error_page/supervised_user_error_page.h" |
22 #include "content/public/browser/interstitial_page_delegate.h" | 24 #include "content/public/browser/interstitial_page_delegate.h" |
23 #include "content/public/browser/render_frame_host.h" | 25 #include "content/public/browser/render_frame_host.h" |
24 #include "content/public/browser/render_process_host.h" | 26 #include "content/public/browser/render_process_host.h" |
25 #include "content/public/browser/url_data_source.h" | 27 #include "content/public/browser/url_data_source.h" |
26 #include "content/public/browser/web_contents.h" | 28 #include "content/public/browser/web_contents.h" |
27 #include "content/public/browser/web_ui.h" | 29 #include "content/public/browser/web_ui.h" |
28 #include "content/public/browser/web_ui_data_source.h" | 30 #include "content/public/browser/web_ui_data_source.h" |
29 #include "crypto/rsa_private_key.h" | 31 #include "crypto/rsa_private_key.h" |
30 #include "net/base/net_errors.h" | 32 #include "net/base/net_errors.h" |
31 #include "net/base/url_util.h" | 33 #include "net/base/url_util.h" |
(...skipping 26 matching lines...) Expand all Loading... |
58 } | 60 } |
59 | 61 |
60 return net::X509Certificate::CreateFromBytes(cert_der.data(), | 62 return net::X509Certificate::CreateFromBytes(cert_der.data(), |
61 cert_der.size()); | 63 cert_der.size()); |
62 } | 64 } |
63 | 65 |
64 // Implementation of chrome://interstitials demonstration pages. This code is | 66 // Implementation of chrome://interstitials demonstration pages. This code is |
65 // not used in displaying any real interstitials. | 67 // not used in displaying any real interstitials. |
66 class InterstitialHTMLSource : public content::URLDataSource { | 68 class InterstitialHTMLSource : public content::URLDataSource { |
67 public: | 69 public: |
68 InterstitialHTMLSource() {} | 70 explicit InterstitialHTMLSource(Profile* profile) : profile_(profile) {} |
69 ~InterstitialHTMLSource() override {} | 71 ~InterstitialHTMLSource() override {} |
70 | 72 |
71 // content::URLDataSource: | 73 // content::URLDataSource: |
72 std::string GetMimeType(const std::string& mime_type) const override; | 74 std::string GetMimeType(const std::string& mime_type) const override; |
73 std::string GetSource() const override; | 75 std::string GetSource() const override; |
74 std::string GetContentSecurityPolicyScriptSrc() const override; | 76 std::string GetContentSecurityPolicyScriptSrc() const override; |
75 std::string GetContentSecurityPolicyStyleSrc() const override; | 77 std::string GetContentSecurityPolicyStyleSrc() const override; |
76 std::string GetContentSecurityPolicyImgSrc() const override; | 78 std::string GetContentSecurityPolicyImgSrc() const override; |
77 void StartDataRequest( | 79 void StartDataRequest( |
78 const std::string& path, | 80 const std::string& path, |
79 const content::ResourceRequestInfo::WebContentsGetter& wc_getter, | 81 const content::ResourceRequestInfo::WebContentsGetter& wc_getter, |
80 const content::URLDataSource::GotDataCallback& callback) override; | 82 const content::URLDataSource::GotDataCallback& callback) override; |
81 | 83 |
82 private: | 84 private: |
| 85 Profile* profile_; |
| 86 |
83 DISALLOW_COPY_AND_ASSIGN(InterstitialHTMLSource); | 87 DISALLOW_COPY_AND_ASSIGN(InterstitialHTMLSource); |
84 }; | 88 }; |
85 | 89 |
86 #if BUILDFLAG(ENABLE_CAPTIVE_PORTAL_DETECTION) | 90 #if BUILDFLAG(ENABLE_CAPTIVE_PORTAL_DETECTION) |
87 // Provides fake connection information to the captive portal blocking page so | 91 // Provides fake connection information to the captive portal blocking page so |
88 // 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. |
89 class CaptivePortalBlockingPageWithNetInfo : public CaptivePortalBlockingPage { | 93 class CaptivePortalBlockingPageWithNetInfo : public CaptivePortalBlockingPage { |
90 public: | 94 public: |
91 CaptivePortalBlockingPageWithNetInfo( | 95 CaptivePortalBlockingPageWithNetInfo( |
92 content::WebContents* web_contents, | 96 content::WebContents* web_contents, |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 is_wifi_connection, wifi_ssid); | 305 is_wifi_connection, wifi_ssid); |
302 return blocking_page; | 306 return blocking_page; |
303 } | 307 } |
304 #endif | 308 #endif |
305 | 309 |
306 } // namespace | 310 } // namespace |
307 | 311 |
308 InterstitialUI::InterstitialUI(content::WebUI* web_ui) | 312 InterstitialUI::InterstitialUI(content::WebUI* web_ui) |
309 : WebUIController(web_ui) { | 313 : WebUIController(web_ui) { |
310 Profile* profile = Profile::FromWebUI(web_ui); | 314 Profile* profile = Profile::FromWebUI(web_ui); |
311 content::URLDataSource::Add(profile, new InterstitialHTMLSource()); | 315 content::URLDataSource::Add(profile, new InterstitialHTMLSource(profile)); |
312 } | 316 } |
313 | 317 |
314 InterstitialUI::~InterstitialUI() { | 318 InterstitialUI::~InterstitialUI() { |
315 } | 319 } |
316 | 320 |
317 // InterstitialHTMLSource | 321 // InterstitialHTMLSource |
318 | 322 |
319 std::string InterstitialHTMLSource::GetMimeType( | 323 std::string InterstitialHTMLSource::GetMimeType( |
320 const std::string& mime_type) const { | 324 const std::string& mime_type) const { |
321 return "text/html"; | 325 return "text/html"; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 interstitial_delegate.reset(CreateBadClockBlockingPage(web_contents)); | 362 interstitial_delegate.reset(CreateBadClockBlockingPage(web_contents)); |
359 } | 363 } |
360 #if BUILDFLAG(ENABLE_CAPTIVE_PORTAL_DETECTION) | 364 #if BUILDFLAG(ENABLE_CAPTIVE_PORTAL_DETECTION) |
361 else if (base::StartsWith(path, "captiveportal", | 365 else if (base::StartsWith(path, "captiveportal", |
362 base::CompareCase::SENSITIVE)) | 366 base::CompareCase::SENSITIVE)) |
363 { | 367 { |
364 interstitial_delegate.reset(CreateCaptivePortalBlockingPage(web_contents)); | 368 interstitial_delegate.reset(CreateCaptivePortalBlockingPage(web_contents)); |
365 } | 369 } |
366 #endif | 370 #endif |
367 std::string html; | 371 std::string html; |
368 if (interstitial_delegate.get()) { | 372 if (base::StartsWith(path, "supervised_user", base::CompareCase::SENSITIVE)) { |
| 373 html = SupervisedUserInterstitial::GetHTMLContents( |
| 374 profile_, profile_->IsChild() |
| 375 ? supervised_user_error_page::ASYNC_CHECKER |
| 376 : supervised_user_error_page::MANUAL); |
| 377 } else if (interstitial_delegate.get()) { |
369 html = interstitial_delegate.get()->GetHTMLContents(); | 378 html = interstitial_delegate.get()->GetHTMLContents(); |
370 } else { | 379 } else { |
371 html = ResourceBundle::GetSharedInstance() | 380 html = ResourceBundle::GetSharedInstance() |
372 .GetRawDataResource(IDR_SECURITY_INTERSTITIAL_UI_HTML) | 381 .GetRawDataResource(IDR_SECURITY_INTERSTITIAL_UI_HTML) |
373 .as_string(); | 382 .as_string(); |
374 } | 383 } |
375 scoped_refptr<base::RefCountedString> html_bytes = new base::RefCountedString; | 384 scoped_refptr<base::RefCountedString> html_bytes = new base::RefCountedString; |
376 html_bytes->data().assign(html.begin(), html.end()); | 385 html_bytes->data().assign(html.begin(), html.end()); |
377 callback.Run(html_bytes.get()); | 386 callback.Run(html_bytes.get()); |
378 } | 387 } |
OLD | NEW |