| 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" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) | 87 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) |
| 88 // Provides fake connection information to the captive portal blocking page so | 88 // Provides fake connection information to the captive portal blocking page so |
| 89 // that both Wi-Fi and non Wi-Fi blocking pages can be displayed. | 89 // that both Wi-Fi and non Wi-Fi blocking pages can be displayed. |
| 90 class CaptivePortalBlockingPageWithNetInfo : public CaptivePortalBlockingPage { | 90 class CaptivePortalBlockingPageWithNetInfo : public CaptivePortalBlockingPage { |
| 91 public: | 91 public: |
| 92 CaptivePortalBlockingPageWithNetInfo( | 92 CaptivePortalBlockingPageWithNetInfo( |
| 93 content::WebContents* web_contents, | 93 content::WebContents* web_contents, |
| 94 const GURL& request_url, | 94 const GURL& request_url, |
| 95 const GURL& login_url, | 95 const GURL& login_url, |
| 96 const net::SSLInfo& ssl_info, | 96 const net::SSLInfo& ssl_info, |
| 97 const base::Callback<void(bool)>& callback, | 97 const base::Callback<void(content::CertificateRequestResultType)>& |
| 98 callback, |
| 98 bool is_wifi, | 99 bool is_wifi, |
| 99 const std::string& wifi_ssid) | 100 const std::string& wifi_ssid) |
| 100 : CaptivePortalBlockingPage(web_contents, | 101 : CaptivePortalBlockingPage(web_contents, |
| 101 request_url, | 102 request_url, |
| 102 login_url, | 103 login_url, |
| 103 nullptr, | 104 nullptr, |
| 104 ssl_info, | 105 ssl_info, |
| 105 callback), | 106 callback), |
| 106 is_wifi_(is_wifi), | 107 is_wifi_(is_wifi), |
| 107 wifi_ssid_(wifi_ssid) {} | 108 wifi_ssid_(wifi_ssid) {} |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 strict_enforcement = strict_enforcement_param == "1"; | 146 strict_enforcement = strict_enforcement_param == "1"; |
| 146 } | 147 } |
| 147 net::SSLInfo ssl_info; | 148 net::SSLInfo ssl_info; |
| 148 ssl_info.cert = ssl_info.unverified_cert = CreateFakeCert(); | 149 ssl_info.cert = ssl_info.unverified_cert = CreateFakeCert(); |
| 149 // This delegate doesn't create an interstitial. | 150 // This delegate doesn't create an interstitial. |
| 150 int options_mask = 0; | 151 int options_mask = 0; |
| 151 if (overridable) | 152 if (overridable) |
| 152 options_mask |= security_interstitials::SSLErrorUI::SOFT_OVERRIDE_ENABLED; | 153 options_mask |= security_interstitials::SSLErrorUI::SOFT_OVERRIDE_ENABLED; |
| 153 if (strict_enforcement) | 154 if (strict_enforcement) |
| 154 options_mask |= security_interstitials::SSLErrorUI::STRICT_ENFORCEMENT; | 155 options_mask |= security_interstitials::SSLErrorUI::STRICT_ENFORCEMENT; |
| 155 return new SSLBlockingPage(web_contents, cert_error, ssl_info, request_url, | 156 return new SSLBlockingPage( |
| 156 options_mask, time_triggered_, nullptr, | 157 web_contents, cert_error, ssl_info, request_url, options_mask, |
| 157 base::Callback<void(bool)>()); | 158 time_triggered_, nullptr, |
| 159 base::Callback<void(content::CertificateRequestResultType)>()); |
| 158 } | 160 } |
| 159 | 161 |
| 160 BadClockBlockingPage* CreateBadClockBlockingPage( | 162 BadClockBlockingPage* CreateBadClockBlockingPage( |
| 161 content::WebContents* web_contents) { | 163 content::WebContents* web_contents) { |
| 162 // Set up a fake clock error. | 164 // Set up a fake clock error. |
| 163 int cert_error = net::ERR_CERT_DATE_INVALID; | 165 int cert_error = net::ERR_CERT_DATE_INVALID; |
| 164 GURL request_url("https://example.com"); | 166 GURL request_url("https://example.com"); |
| 165 bool overridable = false; | 167 bool overridable = false; |
| 166 bool strict_enforcement = false; | 168 bool strict_enforcement = false; |
| 167 std::string url_param; | 169 std::string url_param; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 193 } | 195 } |
| 194 | 196 |
| 195 net::SSLInfo ssl_info; | 197 net::SSLInfo ssl_info; |
| 196 ssl_info.cert = ssl_info.unverified_cert = CreateFakeCert(); | 198 ssl_info.cert = ssl_info.unverified_cert = CreateFakeCert(); |
| 197 // This delegate doesn't create an interstitial. | 199 // This delegate doesn't create an interstitial. |
| 198 int options_mask = 0; | 200 int options_mask = 0; |
| 199 if (overridable) | 201 if (overridable) |
| 200 options_mask |= security_interstitials::SSLErrorUI::SOFT_OVERRIDE_ENABLED; | 202 options_mask |= security_interstitials::SSLErrorUI::SOFT_OVERRIDE_ENABLED; |
| 201 if (strict_enforcement) | 203 if (strict_enforcement) |
| 202 options_mask |= security_interstitials::SSLErrorUI::STRICT_ENFORCEMENT; | 204 options_mask |= security_interstitials::SSLErrorUI::STRICT_ENFORCEMENT; |
| 203 return new BadClockBlockingPage(web_contents, cert_error, ssl_info, | 205 return new BadClockBlockingPage( |
| 204 request_url, base::Time::Now(), clock_state, | 206 web_contents, cert_error, ssl_info, request_url, base::Time::Now(), |
| 205 nullptr, base::Callback<void(bool)>()); | 207 clock_state, nullptr, |
| 208 base::Callback<void(content::CertificateRequestResultType)>()); |
| 206 } | 209 } |
| 207 | 210 |
| 208 safe_browsing::SafeBrowsingBlockingPage* CreateSafeBrowsingBlockingPage( | 211 safe_browsing::SafeBrowsingBlockingPage* CreateSafeBrowsingBlockingPage( |
| 209 content::WebContents* web_contents) { | 212 content::WebContents* web_contents) { |
| 210 safe_browsing::SBThreatType threat_type = | 213 safe_browsing::SBThreatType threat_type = |
| 211 safe_browsing::SB_THREAT_TYPE_URL_MALWARE; | 214 safe_browsing::SB_THREAT_TYPE_URL_MALWARE; |
| 212 GURL request_url("http://example.com"); | 215 GURL request_url("http://example.com"); |
| 213 std::string url_param; | 216 std::string url_param; |
| 214 if (net::GetValueForKeyInQuery(web_contents->GetURL(), | 217 if (net::GetValueForKeyInQuery(web_contents->GetURL(), |
| 215 "url", | 218 "url", |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 std::string wifi_ssid_param; | 290 std::string wifi_ssid_param; |
| 288 if (net::GetValueForKeyInQuery(web_contents->GetURL(), "wifi_name", | 291 if (net::GetValueForKeyInQuery(web_contents->GetURL(), "wifi_name", |
| 289 &wifi_ssid_param)) { | 292 &wifi_ssid_param)) { |
| 290 wifi_ssid = wifi_ssid_param; | 293 wifi_ssid = wifi_ssid_param; |
| 291 } | 294 } |
| 292 net::SSLInfo ssl_info; | 295 net::SSLInfo ssl_info; |
| 293 ssl_info.cert = ssl_info.unverified_cert = CreateFakeCert(); | 296 ssl_info.cert = ssl_info.unverified_cert = CreateFakeCert(); |
| 294 CaptivePortalBlockingPage* blocking_page = | 297 CaptivePortalBlockingPage* blocking_page = |
| 295 new CaptivePortalBlockingPageWithNetInfo( | 298 new CaptivePortalBlockingPageWithNetInfo( |
| 296 web_contents, request_url, landing_url, ssl_info, | 299 web_contents, request_url, landing_url, ssl_info, |
| 297 base::Callback<void(bool)>(), is_wifi_connection, wifi_ssid); | 300 base::Callback<void(content::CertificateRequestResultType)>(), |
| 301 is_wifi_connection, wifi_ssid); |
| 298 return blocking_page; | 302 return blocking_page; |
| 299 } | 303 } |
| 300 #endif | 304 #endif |
| 301 | 305 |
| 302 } // namespace | 306 } // namespace |
| 303 | 307 |
| 304 InterstitialUI::InterstitialUI(content::WebUI* web_ui) | 308 InterstitialUI::InterstitialUI(content::WebUI* web_ui) |
| 305 : WebUIController(web_ui) { | 309 : WebUIController(web_ui) { |
| 306 std::unique_ptr<InterstitialHTMLSource> html_source( | 310 std::unique_ptr<InterstitialHTMLSource> html_source( |
| 307 new InterstitialHTMLSource(web_ui->GetWebContents())); | 311 new InterstitialHTMLSource(web_ui->GetWebContents())); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 html = interstitial_delegate.get()->GetHTMLContents(); | 374 html = interstitial_delegate.get()->GetHTMLContents(); |
| 371 } else { | 375 } else { |
| 372 html = ResourceBundle::GetSharedInstance() | 376 html = ResourceBundle::GetSharedInstance() |
| 373 .GetRawDataResource(IDR_SECURITY_INTERSTITIAL_UI_HTML) | 377 .GetRawDataResource(IDR_SECURITY_INTERSTITIAL_UI_HTML) |
| 374 .as_string(); | 378 .as_string(); |
| 375 } | 379 } |
| 376 scoped_refptr<base::RefCountedString> html_bytes = new base::RefCountedString; | 380 scoped_refptr<base::RefCountedString> html_bytes = new base::RefCountedString; |
| 377 html_bytes->data().assign(html.begin(), html.end()); | 381 html_bytes->data().assign(html.begin(), html.end()); |
| 378 callback.Run(html_bytes.get()); | 382 callback.Run(html_bytes.get()); |
| 379 } | 383 } |
| OLD | NEW |