OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "components/security_interstitials/core/common_string_util.h" |
| 6 |
| 7 #include "base/i18n/rtl.h" |
| 8 #include "base/i18n/time_formatting.h" |
| 9 #include "base/strings/string_util.h" |
| 10 #include "components/url_formatter/url_formatter.h" |
| 11 #include "grit/components_strings.h" |
| 12 #include "net/base/net_errors.h" |
| 13 #include "ui/base/l10n/l10n_util.h" |
| 14 |
| 15 namespace security_interstitials { |
| 16 |
| 17 namespace common_string_util { |
| 18 |
| 19 base::string16 GetFormattedHostName(const GURL& gurl, |
| 20 const std::string& languages) { |
| 21 base::string16 host = url_formatter::IDNToUnicode(gurl.host(), languages); |
| 22 if (base::i18n::IsRTL()) |
| 23 base::i18n::WrapStringWithLTRFormatting(&host); |
| 24 return host; |
| 25 } |
| 26 |
| 27 void PopulateSSLLayoutStrings(int cert_error, |
| 28 base::DictionaryValue* load_time_data) { |
| 29 load_time_data->SetString("type", "SSL"); |
| 30 load_time_data->SetString("errorCode", net::ErrorToString(cert_error)); |
| 31 load_time_data->SetString( |
| 32 "openDetails", l10n_util::GetStringUTF16(IDS_SSL_OPEN_DETAILS_BUTTON)); |
| 33 load_time_data->SetString( |
| 34 "closeDetails", l10n_util::GetStringUTF16(IDS_SSL_CLOSE_DETAILS_BUTTON)); |
| 35 } |
| 36 |
| 37 void PopulateSSLDebuggingStrings(const net::SSLInfo ssl_info, |
| 38 const base::Time time_triggered, |
| 39 base::DictionaryValue* load_time_data) { |
| 40 load_time_data->SetString("subject", |
| 41 ssl_info.cert->subject().GetDisplayName()); |
| 42 load_time_data->SetString("issuer", ssl_info.cert->issuer().GetDisplayName()); |
| 43 load_time_data->SetString( |
| 44 "expirationDate", |
| 45 base::TimeFormatShortDate(ssl_info.cert->valid_expiry())); |
| 46 load_time_data->SetString("currentDate", |
| 47 base::TimeFormatShortDate(time_triggered)); |
| 48 std::vector<std::string> encoded_chain; |
| 49 ssl_info.cert->GetPEMEncodedChain(&encoded_chain); |
| 50 load_time_data->SetString( |
| 51 "pem", base::JoinString(encoded_chain, base::StringPiece())); |
| 52 } |
| 53 |
| 54 } // namespace common_string_util |
| 55 |
| 56 } // namespace security_interstitials |
OLD | NEW |