| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 std::string result; | 42 std::string result; |
| 43 for (size_t i = 0; i < str.size(); i += 64) { | 43 for (size_t i = 0; i < str.size(); i += 64) { |
| 44 result.append(str, i, 64); // Append clamps the len arg internally. | 44 result.append(str, i, 64); // Append clamps the len arg internally. |
| 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 base::Base64Encode(x509_certificate_model::GetDerString(cert), &base64); |
| 53 x509_certificate_model::GetDerString(cert), &base64)) { | |
| 54 LOG(ERROR) << "base64 encoding error"; | |
| 55 return std::string(); | |
| 56 } | |
| 57 return "-----BEGIN CERTIFICATE-----\r\n" + | 53 return "-----BEGIN CERTIFICATE-----\r\n" + |
| 58 WrapAt64(base64) + | 54 WrapAt64(base64) + |
| 59 "-----END CERTIFICATE-----\r\n"; | 55 "-----END CERTIFICATE-----\r\n"; |
| 60 } | 56 } |
| 61 | 57 |
| 62 //////////////////////////////////////////////////////////////////////////////// | 58 //////////////////////////////////////////////////////////////////////////////// |
| 63 // General utility functions. | 59 // General utility functions. |
| 64 | 60 |
| 65 class Exporter : public ui::SelectFileDialog::Listener { | 61 class Exporter : public ui::SelectFileDialog::Listener { |
| 66 public: | 62 public: |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 1, // 1-based index for |file_type_info.extensions| to specify default. | 172 1, // 1-based index for |file_type_info.extensions| to specify default. |
| 177 FILE_PATH_LITERAL("crt"), | 173 FILE_PATH_LITERAL("crt"), |
| 178 parent, params); | 174 parent, params); |
| 179 } | 175 } |
| 180 | 176 |
| 181 void ShowCertExportDialog(WebContents* web_contents, | 177 void ShowCertExportDialog(WebContents* web_contents, |
| 182 gfx::NativeWindow parent, | 178 gfx::NativeWindow parent, |
| 183 net::X509Certificate::OSCertHandle cert) { | 179 net::X509Certificate::OSCertHandle cert) { |
| 184 new Exporter(web_contents, parent, cert); | 180 new Exporter(web_contents, parent, cert); |
| 185 } | 181 } |
| OLD | NEW |