| 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/ssl/captive_portal_blocking_page.h" | 5 #include "chrome/browser/ssl/captive_portal_blocking_page.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| 11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
| 12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 14 #include "base/values.h" | 14 #include "base/values.h" |
| 15 #include "build/build_config.h" | 15 #include "build/build_config.h" |
| 16 #include "chrome/browser/captive_portal/captive_portal_tab_helper.h" | 16 #include "chrome/browser/captive_portal/captive_portal_tab_helper.h" |
| 17 #include "chrome/browser/profiles/profile.h" | |
| 18 #include "chrome/browser/ssl/cert_report_helper.h" | 17 #include "chrome/browser/ssl/cert_report_helper.h" |
| 19 #include "chrome/browser/ssl/ssl_cert_reporter.h" | 18 #include "chrome/browser/ssl/ssl_cert_reporter.h" |
| 20 #include "chrome/common/pref_names.h" | |
| 21 #include "components/captive_portal/captive_portal_detector.h" | 19 #include "components/captive_portal/captive_portal_detector.h" |
| 22 #include "components/certificate_reporting/error_reporter.h" | 20 #include "components/certificate_reporting/error_reporter.h" |
| 23 #include "components/prefs/pref_service.h" | |
| 24 #include "components/security_interstitials/core/controller_client.h" | 21 #include "components/security_interstitials/core/controller_client.h" |
| 25 #include "components/url_formatter/url_formatter.h" | 22 #include "components/url_formatter/url_formatter.h" |
| 26 #include "components/wifi/wifi_service.h" | 23 #include "components/wifi/wifi_service.h" |
| 27 #include "content/public/browser/web_contents.h" | 24 #include "content/public/browser/web_contents.h" |
| 28 #include "grit/generated_resources.h" | 25 #include "grit/generated_resources.h" |
| 29 #include "net/base/network_change_notifier.h" | 26 #include "net/base/network_change_notifier.h" |
| 30 #include "net/base/network_interfaces.h" | 27 #include "net/base/network_interfaces.h" |
| 31 #include "net/ssl/ssl_info.h" | 28 #include "net/ssl/ssl_info.h" |
| 32 #include "ui/base/l10n/l10n_util.h" | 29 #include "ui/base/l10n/l10n_util.h" |
| 33 | 30 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 is_wifi ? IDS_CAPTIVE_PORTAL_PRIMARY_PARAGRAPH_NO_LOGIN_URL_WIFI | 145 is_wifi ? IDS_CAPTIVE_PORTAL_PRIMARY_PARAGRAPH_NO_LOGIN_URL_WIFI |
| 149 : IDS_CAPTIVE_PORTAL_PRIMARY_PARAGRAPH_NO_LOGIN_URL_WIRED); | 146 : IDS_CAPTIVE_PORTAL_PRIMARY_PARAGRAPH_NO_LOGIN_URL_WIRED); |
| 150 } else { | 147 } else { |
| 151 paragraph = l10n_util::GetStringFUTF16( | 148 paragraph = l10n_util::GetStringFUTF16( |
| 152 IDS_CAPTIVE_PORTAL_PRIMARY_PARAGRAPH_NO_LOGIN_URL_WIFI_SSID, | 149 IDS_CAPTIVE_PORTAL_PRIMARY_PARAGRAPH_NO_LOGIN_URL_WIFI_SSID, |
| 153 net::EscapeForHTML(base::UTF8ToUTF16(wifi_ssid))); | 150 net::EscapeForHTML(base::UTF8ToUTF16(wifi_ssid))); |
| 154 } | 151 } |
| 155 } else { | 152 } else { |
| 156 // Portal redirection was done with HTTP redirects, so show the login URL. | 153 // Portal redirection was done with HTTP redirects, so show the login URL. |
| 157 // If |languages| is empty, punycode in |login_host| will always be decoded. | 154 // If |languages| is empty, punycode in |login_host| will always be decoded. |
| 158 std::string languages; | |
| 159 Profile* profile = | |
| 160 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); | |
| 161 if (profile) | |
| 162 languages = profile->GetPrefs()->GetString(prefs::kAcceptLanguages); | |
| 163 base::string16 login_host = | 155 base::string16 login_host = |
| 164 url_formatter::IDNToUnicode(login_url_.host(), languages); | 156 url_formatter::IDNToUnicode(login_url_.host()); |
| 165 if (base::i18n::IsRTL()) | 157 if (base::i18n::IsRTL()) |
| 166 base::i18n::WrapStringWithLTRFormatting(&login_host); | 158 base::i18n::WrapStringWithLTRFormatting(&login_host); |
| 167 | 159 |
| 168 if (wifi_ssid.empty()) { | 160 if (wifi_ssid.empty()) { |
| 169 paragraph = l10n_util::GetStringFUTF16( | 161 paragraph = l10n_util::GetStringFUTF16( |
| 170 is_wifi ? IDS_CAPTIVE_PORTAL_PRIMARY_PARAGRAPH_WIFI | 162 is_wifi ? IDS_CAPTIVE_PORTAL_PRIMARY_PARAGRAPH_WIFI |
| 171 : IDS_CAPTIVE_PORTAL_PRIMARY_PARAGRAPH_WIRED, | 163 : IDS_CAPTIVE_PORTAL_PRIMARY_PARAGRAPH_WIRED, |
| 172 login_host); | 164 login_host); |
| 173 } else { | 165 } else { |
| 174 paragraph = l10n_util::GetStringFUTF16( | 166 paragraph = l10n_util::GetStringFUTF16( |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 certificate_reporting::ErrorReport::USER_DID_NOT_PROCEED); | 214 certificate_reporting::ErrorReport::USER_DID_NOT_PROCEED); |
| 223 } | 215 } |
| 224 | 216 |
| 225 // Need to explicity deny the certificate via the callback, otherwise memory | 217 // Need to explicity deny the certificate via the callback, otherwise memory |
| 226 // is leaked. | 218 // is leaked. |
| 227 if (!callback_.is_null()) { | 219 if (!callback_.is_null()) { |
| 228 callback_.Run(false); | 220 callback_.Run(false); |
| 229 callback_.Reset(); | 221 callback_.Reset(); |
| 230 } | 222 } |
| 231 } | 223 } |
| OLD | NEW |