OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/settings/certificates_handler.h" | 5 #include "chrome/browser/ui/webui/settings/certificates_handler.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 1025 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1036 std::unique_ptr<base::ListValue> nodes = | 1036 std::unique_ptr<base::ListValue> nodes = |
1037 base::MakeUnique<base::ListValue>(); | 1037 base::MakeUnique<base::ListValue>(); |
1038 for (CertificateManagerModel::OrgGroupingMap::iterator i = map.begin(); | 1038 for (CertificateManagerModel::OrgGroupingMap::iterator i = map.begin(); |
1039 i != map.end(); ++i) { | 1039 i != map.end(); ++i) { |
1040 // Populate first level (org name). | 1040 // Populate first level (org name). |
1041 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue); | 1041 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue); |
1042 dict->SetString(kKeyField, OrgNameToId(i->first)); | 1042 dict->SetString(kKeyField, OrgNameToId(i->first)); |
1043 dict->SetString(kNameField, i->first); | 1043 dict->SetString(kNameField, i->first); |
1044 | 1044 |
1045 // Populate second level (certs). | 1045 // Populate second level (certs). |
1046 base::ListValue* subnodes = new base::ListValue; | 1046 auto subnodes = base::MakeUnique<base::ListValue>(); |
1047 for (net::CertificateList::const_iterator org_cert_it = i->second.begin(); | 1047 for (net::CertificateList::const_iterator org_cert_it = i->second.begin(); |
1048 org_cert_it != i->second.end(); ++org_cert_it) { | 1048 org_cert_it != i->second.end(); ++org_cert_it) { |
1049 std::unique_ptr<base::DictionaryValue> cert_dict( | 1049 std::unique_ptr<base::DictionaryValue> cert_dict( |
1050 new base::DictionaryValue); | 1050 new base::DictionaryValue); |
1051 net::X509Certificate* cert = org_cert_it->get(); | 1051 net::X509Certificate* cert = org_cert_it->get(); |
1052 cert_dict->SetString(kKeyField, cert_id_map_->CertToId(cert)); | 1052 cert_dict->SetString(kKeyField, cert_id_map_->CertToId(cert)); |
1053 cert_dict->SetString( | 1053 cert_dict->SetString( |
1054 kNameField, certificate_manager_model_->GetColumnText( | 1054 kNameField, certificate_manager_model_->GetColumnText( |
1055 *cert, CertificateManagerModel::COL_SUBJECT_NAME)); | 1055 *cert, CertificateManagerModel::COL_SUBJECT_NAME)); |
1056 cert_dict->SetBoolean( | 1056 cert_dict->SetBoolean( |
(...skipping 11 matching lines...) Expand all Loading... |
1068 // CKA_EXTRACTABLE attribute. We may need to use the NSS function | 1068 // CKA_EXTRACTABLE attribute. We may need to use the NSS function |
1069 // PK11_ReadRawAttribute to do that. | 1069 // PK11_ReadRawAttribute to do that. |
1070 cert_dict->SetBoolean( | 1070 cert_dict->SetBoolean( |
1071 kExtractableField, | 1071 kExtractableField, |
1072 !certificate_manager_model_->IsHardwareBacked(cert)); | 1072 !certificate_manager_model_->IsHardwareBacked(cert)); |
1073 // TODO(mattm): Other columns. | 1073 // TODO(mattm): Other columns. |
1074 subnodes->Append(std::move(cert_dict)); | 1074 subnodes->Append(std::move(cert_dict)); |
1075 } | 1075 } |
1076 std::sort(subnodes->begin(), subnodes->end(), comparator); | 1076 std::sort(subnodes->begin(), subnodes->end(), comparator); |
1077 | 1077 |
1078 dict->Set(kSubnodesField, subnodes); | 1078 dict->Set(kSubnodesField, std::move(subnodes)); |
1079 nodes->Append(std::move(dict)); | 1079 nodes->Append(std::move(dict)); |
1080 } | 1080 } |
1081 std::sort(nodes->begin(), nodes->end(), comparator); | 1081 std::sort(nodes->begin(), nodes->end(), comparator); |
1082 | 1082 |
1083 CallJavascriptFunction("cr.webUIListenerCallback", | 1083 CallJavascriptFunction("cr.webUIListenerCallback", |
1084 base::Value("certificates-changed"), | 1084 base::Value("certificates-changed"), |
1085 base::Value(tab_name), *nodes); | 1085 base::Value(tab_name), *nodes); |
1086 } | 1086 } |
1087 } | 1087 } |
1088 | 1088 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1137 error_info->Set(kCertificateErrors, | 1137 error_info->Set(kCertificateErrors, |
1138 base::WrapUnique(cert_error_list.release())); | 1138 base::WrapUnique(cert_error_list.release())); |
1139 RejectCallback(*error_info); | 1139 RejectCallback(*error_info); |
1140 } | 1140 } |
1141 | 1141 |
1142 gfx::NativeWindow CertificatesHandler::GetParentWindow() const { | 1142 gfx::NativeWindow CertificatesHandler::GetParentWindow() const { |
1143 return web_ui()->GetWebContents()->GetTopLevelNativeWindow(); | 1143 return web_ui()->GetWebContents()->GetTopLevelNativeWindow(); |
1144 } | 1144 } |
1145 | 1145 |
1146 } // namespace settings | 1146 } // namespace settings |
OLD | NEW |