OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/certificate_dialogs.h" | 5 #include "chrome/browser/ui/certificate_dialogs.h" |
6 | 6 |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/base64.h" | 10 #include "base/base64.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 result.append("\r\n"); | 45 result.append("\r\n"); |
46 } | 46 } |
47 return result; | 47 return result; |
48 } | 48 } |
49 | 49 |
50 std::string GetBase64String(net::X509Certificate::OSCertHandle cert) { | 50 std::string GetBase64String(net::X509Certificate::OSCertHandle cert) { |
51 std::string base64; | 51 std::string base64; |
52 if (!base::Base64Encode( | 52 if (!base::Base64Encode( |
53 x509_certificate_model::GetDerString(cert), &base64)) { | 53 x509_certificate_model::GetDerString(cert), &base64)) { |
54 LOG(ERROR) << "base64 encoding error"; | 54 LOG(ERROR) << "base64 encoding error"; |
55 return ""; | 55 return std::string(); |
56 } | 56 } |
57 return "-----BEGIN CERTIFICATE-----\r\n" + | 57 return "-----BEGIN CERTIFICATE-----\r\n" + |
58 WrapAt64(base64) + | 58 WrapAt64(base64) + |
59 "-----END CERTIFICATE-----\r\n"; | 59 "-----END CERTIFICATE-----\r\n"; |
60 } | 60 } |
61 | 61 |
62 //////////////////////////////////////////////////////////////////////////////// | 62 //////////////////////////////////////////////////////////////////////////////// |
63 // General utility functions. | 63 // General utility functions. |
64 | 64 |
65 class Exporter : public ui::SelectFileDialog::Listener { | 65 class Exporter : public ui::SelectFileDialog::Listener { |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 suggested_path, &file_type_info, 1, | 179 suggested_path, &file_type_info, 1, |
180 FILE_PATH_LITERAL("crt"), | 180 FILE_PATH_LITERAL("crt"), |
181 parent, params); | 181 parent, params); |
182 } | 182 } |
183 | 183 |
184 void ShowCertExportDialog(WebContents* web_contents, | 184 void ShowCertExportDialog(WebContents* web_contents, |
185 gfx::NativeWindow parent, | 185 gfx::NativeWindow parent, |
186 net::X509Certificate::OSCertHandle cert) { | 186 net::X509Certificate::OSCertHandle cert) { |
187 new Exporter(web_contents, parent, cert); | 187 new Exporter(web_contents, parent, cert); |
188 } | 188 } |
OLD | NEW |