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 "base/i18n/rtl.h" | 7 #include "base/i18n/rtl.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/string_util.h" | 11 #include "base/strings/string_util.h" |
12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
13 #include "base/values.h" | 13 #include "base/values.h" |
14 #include "chrome/browser/captive_portal/captive_portal_tab_helper.h" | 14 #include "chrome/browser/captive_portal/captive_portal_tab_helper.h" |
15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/browser/ssl/cert_report_helper.h" | 16 #include "chrome/browser/ssl/cert_report_helper.h" |
17 #include "chrome/browser/ssl/ssl_cert_reporter.h" | 17 #include "chrome/browser/ssl/ssl_cert_reporter.h" |
18 #include "chrome/common/pref_names.h" | 18 #include "chrome/common/pref_names.h" |
19 #include "components/captive_portal/captive_portal_detector.h" | 19 #include "components/captive_portal/captive_portal_detector.h" |
| 20 #include "components/url_formatter/url_formatter.h" |
20 #include "components/wifi/wifi_service.h" | 21 #include "components/wifi/wifi_service.h" |
21 #include "content/public/browser/web_contents.h" | 22 #include "content/public/browser/web_contents.h" |
22 #include "grit/generated_resources.h" | 23 #include "grit/generated_resources.h" |
23 #include "net/base/net_util.h" | 24 #include "net/base/net_util.h" |
24 #include "net/base/network_change_notifier.h" | 25 #include "net/base/network_change_notifier.h" |
25 #include "net/ssl/ssl_info.h" | 26 #include "net/ssl/ssl_info.h" |
26 #include "ui/base/l10n/l10n_util.h" | 27 #include "ui/base/l10n/l10n_util.h" |
27 | 28 |
28 #if !defined(ENABLE_CAPTIVE_PORTAL_DETECTION) | 29 #if !defined(ENABLE_CAPTIVE_PORTAL_DETECTION) |
29 #error This file must be built with ENABLE_CAPTIVE_PORTAL_DETECTION flag. | 30 #error This file must be built with ENABLE_CAPTIVE_PORTAL_DETECTION flag. |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 net::EscapeForHTML(base::UTF8ToUTF16(wifi_ssid)))); | 163 net::EscapeForHTML(base::UTF8ToUTF16(wifi_ssid)))); |
163 } | 164 } |
164 } else { | 165 } else { |
165 // Portal redirection was done with HTTP redirects, so show the login URL. | 166 // Portal redirection was done with HTTP redirects, so show the login URL. |
166 // If |languages| is empty, punycode in |login_host| will always be decoded. | 167 // If |languages| is empty, punycode in |login_host| will always be decoded. |
167 std::string languages; | 168 std::string languages; |
168 Profile* profile = Profile::FromBrowserContext( | 169 Profile* profile = Profile::FromBrowserContext( |
169 web_contents()->GetBrowserContext()); | 170 web_contents()->GetBrowserContext()); |
170 if (profile) | 171 if (profile) |
171 languages = profile->GetPrefs()->GetString(prefs::kAcceptLanguages); | 172 languages = profile->GetPrefs()->GetString(prefs::kAcceptLanguages); |
172 base::string16 login_host = net::IDNToUnicode(login_url_.host(), languages); | 173 base::string16 login_host = |
| 174 url_formatter::IDNToUnicode(login_url_.host(), languages); |
173 if (base::i18n::IsRTL()) | 175 if (base::i18n::IsRTL()) |
174 base::i18n::WrapStringWithLTRFormatting(&login_host); | 176 base::i18n::WrapStringWithLTRFormatting(&login_host); |
175 | 177 |
176 if (wifi_ssid.empty()) { | 178 if (wifi_ssid.empty()) { |
177 load_time_data->SetString( | 179 load_time_data->SetString( |
178 "primaryParagraph", | 180 "primaryParagraph", |
179 l10n_util::GetStringFUTF16( | 181 l10n_util::GetStringFUTF16( |
180 is_wifi_connection ? IDS_CAPTIVE_PORTAL_PRIMARY_PARAGRAPH_WIFI | 182 is_wifi_connection ? IDS_CAPTIVE_PORTAL_PRIMARY_PARAGRAPH_WIFI |
181 : IDS_CAPTIVE_PORTAL_PRIMARY_PARAGRAPH_WIRED, | 183 : IDS_CAPTIVE_PORTAL_PRIMARY_PARAGRAPH_WIRED, |
182 login_host)); | 184 login_host)); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 CertificateErrorReport::USER_DID_NOT_PROCEED); | 235 CertificateErrorReport::USER_DID_NOT_PROCEED); |
234 } | 236 } |
235 | 237 |
236 // Need to explicity deny the certificate via the callback, otherwise memory | 238 // Need to explicity deny the certificate via the callback, otherwise memory |
237 // is leaked. | 239 // is leaked. |
238 if (!callback_.is_null()) { | 240 if (!callback_.is_null()) { |
239 callback_.Run(false); | 241 callback_.Run(false); |
240 callback_.Reset(); | 242 callback_.Reset(); |
241 } | 243 } |
242 } | 244 } |
OLD | NEW |