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 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
673 IDS_SETTINGS_CERTIFICATE_MANAGER_IMPORT_ERROR_TITLE), | 673 IDS_SETTINGS_CERTIFICATE_MANAGER_IMPORT_ERROR_TITLE), |
674 l10n_util::GetStringFUTF8( | 674 l10n_util::GetStringFUTF8( |
675 IDS_SETTINGS_CERTIFICATE_MANAGER_READ_ERROR_FORMAT, | 675 IDS_SETTINGS_CERTIFICATE_MANAGER_READ_ERROR_FORMAT, |
676 UTF8ToUTF16(base::safe_strerror(*read_errno)))); | 676 UTF8ToUTF16(base::safe_strerror(*read_errno)))); |
677 return; | 677 return; |
678 } | 678 } |
679 | 679 |
680 file_data_ = *data; | 680 file_data_ = *data; |
681 | 681 |
682 if (CouldBePFX(file_data_)) { | 682 if (CouldBePFX(file_data_)) { |
683 ResolveCallback(base::FundamentalValue(true)); | 683 ResolveCallback(base::Value(true)); |
684 return; | 684 return; |
685 } | 685 } |
686 | 686 |
687 // Non .p12/.pfx files are assumed to be single/chain certificates without | 687 // Non .p12/.pfx files are assumed to be single/chain certificates without |
688 // private key data. The default extension according to spec is '.crt', | 688 // private key data. The default extension according to spec is '.crt', |
689 // however other extensions are also used in some places to represent these | 689 // however other extensions are also used in some places to represent these |
690 // certificates. | 690 // certificates. |
691 int result = certificate_manager_model_->ImportUserCert(file_data_); | 691 int result = certificate_manager_model_->ImportUserCert(file_data_); |
692 ImportExportCleanup(); | 692 ImportExportCleanup(); |
693 int string_id; | 693 int string_id; |
694 switch (result) { | 694 switch (result) { |
695 case net::OK: | 695 case net::OK: |
696 ResolveCallback(base::FundamentalValue(false)); | 696 ResolveCallback(base::Value(false)); |
697 return; | 697 return; |
698 case net::ERR_NO_PRIVATE_KEY_FOR_CERT: | 698 case net::ERR_NO_PRIVATE_KEY_FOR_CERT: |
699 string_id = IDS_SETTINGS_CERTIFICATE_MANAGER_IMPORT_MISSING_KEY; | 699 string_id = IDS_SETTINGS_CERTIFICATE_MANAGER_IMPORT_MISSING_KEY; |
700 break; | 700 break; |
701 case net::ERR_CERT_INVALID: | 701 case net::ERR_CERT_INVALID: |
702 string_id = IDS_SETTINGS_CERTIFICATE_MANAGER_IMPORT_INVALID_FILE; | 702 string_id = IDS_SETTINGS_CERTIFICATE_MANAGER_IMPORT_INVALID_FILE; |
703 break; | 703 break; |
704 default: | 704 default: |
705 string_id = IDS_SETTINGS_CERTIFICATE_MANAGER_UNKNOWN_ERROR; | 705 string_id = IDS_SETTINGS_CERTIFICATE_MANAGER_UNKNOWN_ERROR; |
706 break; | 706 break; |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
978 } | 978 } |
979 } | 979 } |
980 | 980 |
981 void CertificatesHandler::OnCertificateManagerModelCreated( | 981 void CertificatesHandler::OnCertificateManagerModelCreated( |
982 std::unique_ptr<CertificateManagerModel> model) { | 982 std::unique_ptr<CertificateManagerModel> model) { |
983 certificate_manager_model_ = std::move(model); | 983 certificate_manager_model_ = std::move(model); |
984 CertificateManagerModelReady(); | 984 CertificateManagerModelReady(); |
985 } | 985 } |
986 | 986 |
987 void CertificatesHandler::CertificateManagerModelReady() { | 987 void CertificatesHandler::CertificateManagerModelReady() { |
988 base::FundamentalValue user_db_available_value( | 988 base::Value user_db_available_value( |
989 certificate_manager_model_->is_user_db_available()); | 989 certificate_manager_model_->is_user_db_available()); |
990 base::FundamentalValue tpm_available_value( | 990 base::Value tpm_available_value( |
991 certificate_manager_model_->is_tpm_available()); | 991 certificate_manager_model_->is_tpm_available()); |
992 CallJavascriptFunction("cr.webUIListenerCallback", | 992 CallJavascriptFunction("cr.webUIListenerCallback", |
993 base::StringValue("certificates-model-ready"), | 993 base::StringValue("certificates-model-ready"), |
994 user_db_available_value, tpm_available_value); | 994 user_db_available_value, tpm_available_value); |
995 certificate_manager_model_->Refresh(); | 995 certificate_manager_model_->Refresh(); |
996 } | 996 } |
997 | 997 |
998 void CertificatesHandler::HandleRefreshCertificates( | 998 void CertificatesHandler::HandleRefreshCertificates( |
999 const base::ListValue* args) { | 999 const base::ListValue* args) { |
1000 AllowJavascript(); | 1000 AllowJavascript(); |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1140 error_info->Set(kCertificateErrors, | 1140 error_info->Set(kCertificateErrors, |
1141 base::WrapUnique(cert_error_list.release())); | 1141 base::WrapUnique(cert_error_list.release())); |
1142 RejectCallback(*error_info); | 1142 RejectCallback(*error_info); |
1143 } | 1143 } |
1144 | 1144 |
1145 gfx::NativeWindow CertificatesHandler::GetParentWindow() const { | 1145 gfx::NativeWindow CertificatesHandler::GetParentWindow() const { |
1146 return web_ui()->GetWebContents()->GetTopLevelNativeWindow(); | 1146 return web_ui()->GetWebContents()->GetTopLevelNativeWindow(); |
1147 } | 1147 } |
1148 | 1148 |
1149 } // namespace settings | 1149 } // namespace settings |
OLD | NEW |