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 // TODO(mattm): this isn't gtk specific, it shouldn't be under the gtk dir | 5 // TODO(mattm): this isn't gtk specific, it shouldn't be under the gtk dir |
6 | 6 |
7 #include "chrome/browser/ui/gtk/certificate_dialogs.h" | 7 #include "chrome/browser/ui/gtk/certificate_dialogs.h" |
8 | 8 |
9 | 9 |
10 #include <vector> | 10 #include <vector> |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 private: | 83 private: |
84 scoped_refptr<SelectFileDialog> select_file_dialog_; | 84 scoped_refptr<SelectFileDialog> select_file_dialog_; |
85 | 85 |
86 // The certificate hierarchy (leaf cert first). | 86 // The certificate hierarchy (leaf cert first). |
87 net::X509Certificate::OSCertHandles cert_chain_list_; | 87 net::X509Certificate::OSCertHandles cert_chain_list_; |
88 }; | 88 }; |
89 | 89 |
90 Exporter::Exporter(gfx::NativeWindow parent, | 90 Exporter::Exporter(gfx::NativeWindow parent, |
91 net::X509Certificate::OSCertHandle cert) | 91 net::X509Certificate::OSCertHandle cert) |
92 : select_file_dialog_(SelectFileDialog::Create(this)) { | 92 : select_file_dialog_(SelectFileDialog::Create(this)) { |
93 x509_certificate_model::GetCertChainFromCert(cert, &cert_chain_list_); | 93 net::X509Certificate::GetCertChainFromCert(cert, &cert_chain_list_); |
94 | 94 |
95 // TODO(mattm): should this default to some directory? | 95 // TODO(mattm): should this default to some directory? |
96 // Maybe SavePackage::GetSaveDirPreference? (Except that it's private.) | 96 // Maybe SavePackage::GetSaveDirPreference? (Except that it's private.) |
97 FilePath suggested_path("certificate"); | 97 FilePath suggested_path("certificate"); |
98 std::string cert_title = x509_certificate_model::GetTitle(cert); | 98 std::string cert_title = x509_certificate_model::GetTitle(cert); |
99 if (!cert_title.empty()) | 99 if (!cert_title.empty()) |
100 suggested_path = FilePath(cert_title); | 100 suggested_path = FilePath(cert_title); |
101 | 101 |
102 ShowCertSelectFileDialog(select_file_dialog_.get(), | 102 ShowCertSelectFileDialog(select_file_dialog_.get(), |
103 SelectFileDialog::SELECT_SAVEAS_FILE, | 103 SelectFileDialog::SELECT_SAVEAS_FILE, |
104 suggested_path, | 104 suggested_path, |
105 parent, | 105 parent, |
106 NULL); | 106 NULL); |
107 } | 107 } |
108 | 108 |
109 Exporter::~Exporter() { | 109 Exporter::~Exporter() { |
110 // There may be pending file dialogs, we need to tell them that we've gone | 110 // There may be pending file dialogs, we need to tell them that we've gone |
111 // away so they don't try and call back to us. | 111 // away so they don't try and call back to us. |
112 if (select_file_dialog_.get()) | 112 if (select_file_dialog_.get()) |
113 select_file_dialog_->ListenerDestroyed(); | 113 select_file_dialog_->ListenerDestroyed(); |
114 | 114 |
115 x509_certificate_model::DestroyCertChain(&cert_chain_list_); | 115 net::X509Certificate::DestroyCertChain(&cert_chain_list_); |
116 } | 116 } |
117 | 117 |
118 void Exporter::FileSelected(const FilePath& path, int index, void* params) { | 118 void Exporter::FileSelected(const FilePath& path, int index, void* params) { |
119 std::string data; | 119 std::string data; |
120 switch (index) { | 120 switch (index) { |
121 case 2: | 121 case 2: |
122 for (size_t i = 0; i < cert_chain_list_.size(); ++i) | 122 for (size_t i = 0; i < cert_chain_list_.size(); ++i) |
123 data += GetBase64String(cert_chain_list_[i]); | 123 data += GetBase64String(cert_chain_list_[i]); |
124 break; | 124 break; |
125 case 3: | 125 case 3: |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 type, string16(), | 179 type, string16(), |
180 suggested_path, &file_type_info, 1, | 180 suggested_path, &file_type_info, 1, |
181 FILE_PATH_LITERAL("crt"), parent, | 181 FILE_PATH_LITERAL("crt"), parent, |
182 params); | 182 params); |
183 } | 183 } |
184 | 184 |
185 void ShowCertExportDialog(gfx::NativeWindow parent, | 185 void ShowCertExportDialog(gfx::NativeWindow parent, |
186 net::X509Certificate::OSCertHandle cert) { | 186 net::X509Certificate::OSCertHandle cert) { |
187 new Exporter(parent, cert); | 187 new Exporter(parent, cert); |
188 } | 188 } |
OLD | NEW |