| 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 970 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 981 std::unique_ptr<CertificateManagerModel> model) { | 981 std::unique_ptr<CertificateManagerModel> model) { |
| 982 certificate_manager_model_ = std::move(model); | 982 certificate_manager_model_ = std::move(model); |
| 983 CertificateManagerModelReady(); | 983 CertificateManagerModelReady(); |
| 984 } | 984 } |
| 985 | 985 |
| 986 void CertificatesHandler::CertificateManagerModelReady() { | 986 void CertificatesHandler::CertificateManagerModelReady() { |
| 987 base::Value user_db_available_value( | 987 base::Value user_db_available_value( |
| 988 certificate_manager_model_->is_user_db_available()); | 988 certificate_manager_model_->is_user_db_available()); |
| 989 base::Value tpm_available_value( | 989 base::Value tpm_available_value( |
| 990 certificate_manager_model_->is_tpm_available()); | 990 certificate_manager_model_->is_tpm_available()); |
| 991 CallJavascriptFunction("cr.webUIListenerCallback", | 991 FireWebUIListener("certificates-model-ready", user_db_available_value, |
| 992 base::Value("certificates-model-ready"), | 992 tpm_available_value); |
| 993 user_db_available_value, tpm_available_value); | |
| 994 certificate_manager_model_->Refresh(); | 993 certificate_manager_model_->Refresh(); |
| 995 } | 994 } |
| 996 | 995 |
| 997 void CertificatesHandler::HandleRefreshCertificates( | 996 void CertificatesHandler::HandleRefreshCertificates( |
| 998 const base::ListValue* args) { | 997 const base::ListValue* args) { |
| 999 AllowJavascript(); | 998 AllowJavascript(); |
| 1000 | 999 |
| 1001 if (certificate_manager_model_) { | 1000 if (certificate_manager_model_) { |
| 1002 // Already have a model, the webui must be re-loading. Just re-run the | 1001 // Already have a model, the webui must be re-loading. Just re-run the |
| 1003 // webui initialization. | 1002 // webui initialization. |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1075 // TODO(mattm): Other columns. | 1074 // TODO(mattm): Other columns. |
| 1076 subnodes->Append(std::move(cert_dict)); | 1075 subnodes->Append(std::move(cert_dict)); |
| 1077 } | 1076 } |
| 1078 std::sort(subnodes->begin(), subnodes->end(), comparator); | 1077 std::sort(subnodes->begin(), subnodes->end(), comparator); |
| 1079 | 1078 |
| 1080 dict->Set(kSubnodesField, std::move(subnodes)); | 1079 dict->Set(kSubnodesField, std::move(subnodes)); |
| 1081 nodes->Append(std::move(dict)); | 1080 nodes->Append(std::move(dict)); |
| 1082 } | 1081 } |
| 1083 std::sort(nodes->begin(), nodes->end(), comparator); | 1082 std::sort(nodes->begin(), nodes->end(), comparator); |
| 1084 | 1083 |
| 1085 CallJavascriptFunction("cr.webUIListenerCallback", | 1084 FireWebUIListener("certificates-changed", base::Value(tab_name), *nodes); |
| 1086 base::Value("certificates-changed"), | |
| 1087 base::Value(tab_name), *nodes); | |
| 1088 } | 1085 } |
| 1089 } | 1086 } |
| 1090 | 1087 |
| 1091 void CertificatesHandler::ResolveCallback(const base::Value& response) { | 1088 void CertificatesHandler::ResolveCallback(const base::Value& response) { |
| 1092 DCHECK(!webui_callback_id_.empty()); | 1089 DCHECK(!webui_callback_id_.empty()); |
| 1093 ResolveJavascriptCallback(base::Value(webui_callback_id_), response); | 1090 ResolveJavascriptCallback(base::Value(webui_callback_id_), response); |
| 1094 webui_callback_id_.clear(); | 1091 webui_callback_id_.clear(); |
| 1095 } | 1092 } |
| 1096 | 1093 |
| 1097 void CertificatesHandler::RejectCallback(const base::Value& response) { | 1094 void CertificatesHandler::RejectCallback(const base::Value& response) { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1139 error_info->Set(kCertificateErrors, | 1136 error_info->Set(kCertificateErrors, |
| 1140 base::WrapUnique(cert_error_list.release())); | 1137 base::WrapUnique(cert_error_list.release())); |
| 1141 RejectCallback(*error_info); | 1138 RejectCallback(*error_info); |
| 1142 } | 1139 } |
| 1143 | 1140 |
| 1144 gfx::NativeWindow CertificatesHandler::GetParentWindow() const { | 1141 gfx::NativeWindow CertificatesHandler::GetParentWindow() const { |
| 1145 return web_ui()->GetWebContents()->GetTopLevelNativeWindow(); | 1142 return web_ui()->GetWebContents()->GetTopLevelNativeWindow(); |
| 1146 } | 1143 } |
| 1147 | 1144 |
| 1148 } // namespace settings | 1145 } // namespace settings |
| OLD | NEW |