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/webui/certificate_viewer_webui.h" | 5 #include "chrome/browser/ui/webui/certificate_viewer_webui.h" |
6 | 6 |
| 7 #include <memory> |
| 8 #include <utility> |
| 9 |
7 #include "base/bind.h" | 10 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
9 #include "base/i18n/time_formatting.h" | 12 #include "base/i18n/time_formatting.h" |
10 #include "base/json/json_writer.h" | 13 #include "base/json/json_writer.h" |
11 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
12 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
13 #include "chrome/browser/certificate_viewer.h" | 16 #include "chrome/browser/certificate_viewer.h" |
14 #include "chrome/browser/platform_util.h" | 17 #include "chrome/browser/platform_util.h" |
15 #include "chrome/browser/ui/browser_dialogs.h" | 18 #include "chrome/browser/ui/browser_dialogs.h" |
16 #include "chrome/browser/ui/certificate_dialogs.h" | 19 #include "chrome/browser/ui/certificate_dialogs.h" |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 cert_info.SetString("general.sha256", | 165 cert_info.SetString("general.sha256", |
163 x509_certificate_model::HashCertSHA256(cert_hnd)); | 166 x509_certificate_model::HashCertSHA256(cert_hnd)); |
164 cert_info.SetString("general.sha1", | 167 cert_info.SetString("general.sha1", |
165 x509_certificate_model::HashCertSHA1(cert_hnd)); | 168 x509_certificate_model::HashCertSHA1(cert_hnd)); |
166 | 169 |
167 // Certificate hierarchy is constructed from bottom up. | 170 // Certificate hierarchy is constructed from bottom up. |
168 base::ListValue* children = NULL; | 171 base::ListValue* children = NULL; |
169 int index = 0; | 172 int index = 0; |
170 for (net::X509Certificate::OSCertHandles::const_iterator i = | 173 for (net::X509Certificate::OSCertHandles::const_iterator i = |
171 cert_chain.begin(); i != cert_chain.end(); ++i, ++index) { | 174 cert_chain.begin(); i != cert_chain.end(); ++i, ++index) { |
172 base::DictionaryValue* cert_node = new base::DictionaryValue(); | 175 std::unique_ptr<base::DictionaryValue> cert_node( |
| 176 new base::DictionaryValue()); |
173 base::ListValue cert_details; | 177 base::ListValue cert_details; |
174 cert_node->SetString("label", x509_certificate_model::GetTitle(*i).c_str()); | 178 cert_node->SetString("label", x509_certificate_model::GetTitle(*i).c_str()); |
175 cert_node->SetDouble("payload.index", index); | 179 cert_node->SetDouble("payload.index", index); |
176 // Add the child from the previous iteration. | 180 // Add the child from the previous iteration. |
177 if (children) | 181 if (children) |
178 cert_node->Set("children", children); | 182 cert_node->Set("children", children); |
179 | 183 |
180 // Add this node to the children list for the next iteration. | 184 // Add this node to the children list for the next iteration. |
181 children = new base::ListValue(); | 185 children = new base::ListValue(); |
182 children->Append(cert_node); | 186 children->Append(std::move(cert_node)); |
183 } | 187 } |
184 // Set the last node as the top of the certificate hierarchy. | 188 // Set the last node as the top of the certificate hierarchy. |
185 cert_info.Set("hierarchy", children); | 189 cert_info.Set("hierarchy", children); |
186 | 190 |
187 base::JSONWriter::Write(cert_info, &data); | 191 base::JSONWriter::Write(cert_info, &data); |
188 | 192 |
189 return data; | 193 return data; |
190 } | 194 } |
191 | 195 |
192 void CertificateViewerModalDialog::OnDialogShown( | 196 void CertificateViewerModalDialog::OnDialogShown( |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 const base::ListValue* args) const { | 439 const base::ListValue* args) const { |
436 int cert_index; | 440 int cert_index; |
437 double val; | 441 double val; |
438 if (!(args->GetDouble(0, &val))) | 442 if (!(args->GetDouble(0, &val))) |
439 return -1; | 443 return -1; |
440 cert_index = static_cast<int>(val); | 444 cert_index = static_cast<int>(val); |
441 if (cert_index < 0 || cert_index >= static_cast<int>(cert_chain_.size())) | 445 if (cert_index < 0 || cert_index >= static_cast<int>(cert_chain_.size())) |
442 return -1; | 446 return -1; |
443 return cert_index; | 447 return cert_index; |
444 } | 448 } |
OLD | NEW |