Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(452)

Side by Side Diff: chrome/browser/ui/webui/settings/certificates_handler.cc

Issue 1961183002: MD Settings: Update some Settings handlers to use new JS lifecycle management. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 967 matching lines...) Expand 10 before | Expand all | Expand 10 after
978 std::unique_ptr<CertificateManagerModel> model) { 978 std::unique_ptr<CertificateManagerModel> model) {
979 certificate_manager_model_ = std::move(model); 979 certificate_manager_model_ = std::move(model);
980 CertificateManagerModelReady(); 980 CertificateManagerModelReady();
981 } 981 }
982 982
983 void CertificatesHandler::CertificateManagerModelReady() { 983 void CertificatesHandler::CertificateManagerModelReady() {
984 base::FundamentalValue user_db_available_value( 984 base::FundamentalValue user_db_available_value(
985 certificate_manager_model_->is_user_db_available()); 985 certificate_manager_model_->is_user_db_available());
986 base::FundamentalValue tpm_available_value( 986 base::FundamentalValue tpm_available_value(
987 certificate_manager_model_->is_tpm_available()); 987 certificate_manager_model_->is_tpm_available());
988 web_ui()->CallJavascriptFunction( 988 CallJavascriptFunction("cr.webUIListenerCallback",
989 "cr.webUIListenerCallback", base::StringValue("certificates-model-ready"), 989 base::StringValue("certificates-model-ready"),
990 user_db_available_value, tpm_available_value); 990 user_db_available_value, tpm_available_value);
991 certificate_manager_model_->Refresh(); 991 certificate_manager_model_->Refresh();
992 } 992 }
993 993
994 void CertificatesHandler::HandleRefreshCertificates( 994 void CertificatesHandler::HandleRefreshCertificates(
995 const base::ListValue* args) { 995 const base::ListValue* args) {
996 AllowJavascript();
997
996 if (certificate_manager_model_) { 998 if (certificate_manager_model_) {
997 // Already have a model, the webui must be re-loading. Just re-run the 999 // Already have a model, the webui must be re-loading. Just re-run the
998 // webui initialization. 1000 // webui initialization.
999 CertificateManagerModelReady(); 1001 CertificateManagerModelReady();
1000 return; 1002 return;
1001 } 1003 }
1002 1004
1003 if (!requested_certificate_manager_model_) { 1005 if (!requested_certificate_manager_model_) {
1004 // Request that a model be created. 1006 // Request that a model be created.
1005 CertificateManagerModel::Create( 1007 CertificateManagerModel::Create(
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1069 // TODO(mattm): Other columns. 1071 // TODO(mattm): Other columns.
1070 subnodes->Append(cert_dict); 1072 subnodes->Append(cert_dict);
1071 } 1073 }
1072 std::sort(subnodes->begin(), subnodes->end(), comparator); 1074 std::sort(subnodes->begin(), subnodes->end(), comparator);
1073 1075
1074 dict->Set(kSubnodesField, subnodes); 1076 dict->Set(kSubnodesField, subnodes);
1075 nodes->Append(dict); 1077 nodes->Append(dict);
1076 } 1078 }
1077 std::sort(nodes->begin(), nodes->end(), comparator); 1079 std::sort(nodes->begin(), nodes->end(), comparator);
1078 1080
1079 web_ui()->CallJavascriptFunction("cr.webUIListenerCallback", 1081 CallJavascriptFunction("cr.webUIListenerCallback",
1080 base::StringValue("certificates-changed"), 1082 base::StringValue("certificates-changed"),
1081 base::StringValue(tab_name), *nodes); 1083 base::StringValue(tab_name), *nodes);
1082 } 1084 }
1083 } 1085 }
1084 1086
1085 void CertificatesHandler::ResolveCallback(const base::Value& response) { 1087 void CertificatesHandler::ResolveCallback(const base::Value& response) {
1086 DCHECK(!webui_callback_id_.empty()); 1088 DCHECK(!webui_callback_id_.empty());
1087 ResolveJavascriptCallback(base::StringValue(webui_callback_id_), response); 1089 ResolveJavascriptCallback(base::StringValue(webui_callback_id_), response);
1088 webui_callback_id_.clear(); 1090 webui_callback_id_.clear();
1089 } 1091 }
1090 1092
1091 void CertificatesHandler::RejectCallback(const base::Value& response) { 1093 void CertificatesHandler::RejectCallback(const base::Value& response) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1133 error_info->Set(kCertificateErrors, 1135 error_info->Set(kCertificateErrors,
1134 base::WrapUnique(cert_error_list.release())); 1136 base::WrapUnique(cert_error_list.release()));
1135 RejectCallback(*error_info); 1137 RejectCallback(*error_info);
1136 } 1138 }
1137 1139
1138 gfx::NativeWindow CertificatesHandler::GetParentWindow() const { 1140 gfx::NativeWindow CertificatesHandler::GetParentWindow() const {
1139 return web_ui()->GetWebContents()->GetTopLevelNativeWindow(); 1141 return web_ui()->GetWebContents()->GetTopLevelNativeWindow();
1140 } 1142 }
1141 1143
1142 } // namespace settings 1144 } // namespace settings
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698