OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/common/net/x509_certificate_model.h" | 5 #include "chrome/common/net/x509_certificate_model.h" |
6 | 6 |
7 #include <unicode/uidna.h> | 7 #include <unicode/uidna.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
12 #include "chrome/grit/generated_resources.h" | 12 #include "chrome/grit/generated_resources.h" |
13 #include "net/base/net_util.h" | 13 #include "components/url_formatter/url_formatter.h" |
14 #include "ui/base/l10n/l10n_util.h" | 14 #include "ui/base/l10n/l10n_util.h" |
15 | 15 |
16 namespace x509_certificate_model { | 16 namespace x509_certificate_model { |
17 | 17 |
18 std::string ProcessIDN(const std::string& input) { | 18 std::string ProcessIDN(const std::string& input) { |
19 // Convert the ASCII input to a string16 for ICU. | 19 // Convert the ASCII input to a string16 for ICU. |
20 base::string16 input16; | 20 base::string16 input16; |
21 input16.reserve(input.length()); | 21 input16.reserve(input.length()); |
22 input16.insert(input16.end(), input.begin(), input.end()); | 22 input16.insert(input16.end(), input.begin(), input.end()); |
23 | 23 |
24 base::string16 output16 = net::IDNToUnicode(input, std::string()); | 24 base::string16 output16 = url_formatter::IDNToUnicode(input, std::string()); |
25 if (input16 == output16) | 25 if (input16 == output16) |
26 return input; // Input did not contain any encoded data. | 26 return input; // Input did not contain any encoded data. |
27 | 27 |
28 // Input contained encoded data, return formatted string showing original and | 28 // Input contained encoded data, return formatted string showing original and |
29 // decoded forms. | 29 // decoded forms. |
30 return l10n_util::GetStringFUTF8(IDS_CERT_INFO_IDN_VALUE_FORMAT, | 30 return l10n_util::GetStringFUTF8(IDS_CERT_INFO_IDN_VALUE_FORMAT, |
31 input16, output16); | 31 input16, output16); |
32 } | 32 } |
33 | 33 |
34 std::string ProcessRawBytesWithSeparators(const unsigned char* data, | 34 std::string ProcessRawBytesWithSeparators(const unsigned char* data, |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 } | 66 } |
67 | 67 |
68 #if defined(USE_NSS_CERTS) | 68 #if defined(USE_NSS_CERTS) |
69 std::string ProcessRawBits(const unsigned char* data, size_t data_length) { | 69 std::string ProcessRawBits(const unsigned char* data, size_t data_length) { |
70 return ProcessRawBytes(data, (data_length + 7) / 8); | 70 return ProcessRawBytes(data, (data_length + 7) / 8); |
71 } | 71 } |
72 #endif // USE_NSS_CERTS | 72 #endif // USE_NSS_CERTS |
73 | 73 |
74 } // namespace x509_certificate_model | 74 } // namespace x509_certificate_model |
75 | 75 |
OLD | NEW |