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

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

Issue 2792573002: Remove base::Value::CreateNullValue (Closed)
Patch Set: Rebase Created 3 years, 8 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 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 } 451 }
452 } 452 }
453 453
454 void CertificatesHandler::FileSelectionCanceled(void* params) { 454 void CertificatesHandler::FileSelectionCanceled(void* params) {
455 switch (reinterpret_cast<intptr_t>(params)) { 455 switch (reinterpret_cast<intptr_t>(params)) {
456 case EXPORT_PERSONAL_FILE_SELECTED: 456 case EXPORT_PERSONAL_FILE_SELECTED:
457 case IMPORT_PERSONAL_FILE_SELECTED: 457 case IMPORT_PERSONAL_FILE_SELECTED:
458 case IMPORT_SERVER_FILE_SELECTED: 458 case IMPORT_SERVER_FILE_SELECTED:
459 case IMPORT_CA_FILE_SELECTED: 459 case IMPORT_CA_FILE_SELECTED:
460 ImportExportCleanup(); 460 ImportExportCleanup();
461 RejectCallback(*base::Value::CreateNullValue()); 461 RejectCallback(base::Value());
462 break; 462 break;
463 default: 463 default:
464 NOTREACHED(); 464 NOTREACHED();
465 } 465 }
466 } 466 }
467 467
468 void CertificatesHandler::HandleViewCertificate(const base::ListValue* args) { 468 void CertificatesHandler::HandleViewCertificate(const base::ListValue* args) {
469 net::X509Certificate* cert = cert_id_map_->CallbackArgsToCert(args); 469 net::X509Certificate* cert = cert_id_map_->CallbackArgsToCert(args);
470 if (!cert) 470 if (!cert)
471 return; 471 return;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 trust_email * net::NSSCertDatabase::TRUSTED_EMAIL + 534 trust_email * net::NSSCertDatabase::TRUSTED_EMAIL +
535 trust_obj_sign * net::NSSCertDatabase::TRUSTED_OBJ_SIGN); 535 trust_obj_sign * net::NSSCertDatabase::TRUSTED_OBJ_SIGN);
536 if (!result) { 536 if (!result) {
537 // TODO(mattm): better error messages? 537 // TODO(mattm): better error messages?
538 RejectCallbackWithError( 538 RejectCallbackWithError(
539 l10n_util::GetStringUTF8( 539 l10n_util::GetStringUTF8(
540 IDS_SETTINGS_CERTIFICATE_MANAGER_SET_TRUST_ERROR_TITLE), 540 IDS_SETTINGS_CERTIFICATE_MANAGER_SET_TRUST_ERROR_TITLE),
541 l10n_util::GetStringUTF8( 541 l10n_util::GetStringUTF8(
542 IDS_SETTINGS_CERTIFICATE_MANAGER_UNKNOWN_ERROR)); 542 IDS_SETTINGS_CERTIFICATE_MANAGER_UNKNOWN_ERROR));
543 } else { 543 } else {
544 ResolveCallback(*base::Value::CreateNullValue()); 544 ResolveCallback(base::Value());
545 } 545 }
546 } 546 }
547 547
548 void CertificatesHandler::HandleExportPersonal(const base::ListValue* args) { 548 void CertificatesHandler::HandleExportPersonal(const base::ListValue* args) {
549 CHECK_EQ(2U, args->GetSize()); 549 CHECK_EQ(2U, args->GetSize());
550 AssignWebUICallbackId(args); 550 AssignWebUICallbackId(args);
551 std::string node_id; 551 std::string node_id;
552 CHECK(args->GetString(1, &node_id)); 552 CHECK(args->GetString(1, &node_id));
553 553
554 net::X509Certificate* cert = cert_id_map_->IdToCert(node_id); 554 net::X509Certificate* cert = cert_id_map_->IdToCert(node_id);
(...skipping 11 matching lines...) Expand all
566 select_file_dialog_->SelectFile( 566 select_file_dialog_->SelectFile(
567 ui::SelectFileDialog::SELECT_SAVEAS_FILE, base::string16(), 567 ui::SelectFileDialog::SELECT_SAVEAS_FILE, base::string16(),
568 base::FilePath(), &file_type_info, 1, FILE_PATH_LITERAL("p12"), 568 base::FilePath(), &file_type_info, 1, FILE_PATH_LITERAL("p12"),
569 GetParentWindow(), 569 GetParentWindow(),
570 reinterpret_cast<void*>(EXPORT_PERSONAL_FILE_SELECTED)); 570 reinterpret_cast<void*>(EXPORT_PERSONAL_FILE_SELECTED));
571 } 571 }
572 572
573 void CertificatesHandler::ExportPersonalFileSelected( 573 void CertificatesHandler::ExportPersonalFileSelected(
574 const base::FilePath& path) { 574 const base::FilePath& path) {
575 file_path_ = path; 575 file_path_ = path;
576 ResolveCallback(*base::Value::CreateNullValue()); 576 ResolveCallback(base::Value());
577 } 577 }
578 578
579 void CertificatesHandler::HandleExportPersonalPasswordSelected( 579 void CertificatesHandler::HandleExportPersonalPasswordSelected(
580 const base::ListValue* args) { 580 const base::ListValue* args) {
581 CHECK_EQ(2U, args->GetSize()); 581 CHECK_EQ(2U, args->GetSize());
582 AssignWebUICallbackId(args); 582 AssignWebUICallbackId(args);
583 CHECK(args->GetString(1, &password_)); 583 CHECK(args->GetString(1, &password_));
584 584
585 // Currently, we don't support exporting more than one at a time. If we do, 585 // Currently, we don't support exporting more than one at a time. If we do,
586 // this would need to either change this to use UnlockSlotsIfNecessary or 586 // this would need to either change this to use UnlockSlotsIfNecessary or
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 const int* bytes_written) { 620 const int* bytes_written) {
621 ImportExportCleanup(); 621 ImportExportCleanup();
622 if (*write_errno) { 622 if (*write_errno) {
623 RejectCallbackWithError( 623 RejectCallbackWithError(
624 l10n_util::GetStringUTF8( 624 l10n_util::GetStringUTF8(
625 IDS_SETTINGS_CERTIFICATE_MANAGER_PKCS12_EXPORT_ERROR_TITLE), 625 IDS_SETTINGS_CERTIFICATE_MANAGER_PKCS12_EXPORT_ERROR_TITLE),
626 l10n_util::GetStringFUTF8( 626 l10n_util::GetStringFUTF8(
627 IDS_SETTINGS_CERTIFICATE_MANAGER_WRITE_ERROR_FORMAT, 627 IDS_SETTINGS_CERTIFICATE_MANAGER_WRITE_ERROR_FORMAT,
628 UTF8ToUTF16(base::safe_strerror(*write_errno)))); 628 UTF8ToUTF16(base::safe_strerror(*write_errno))));
629 } else { 629 } else {
630 ResolveCallback(*base::Value::CreateNullValue()); 630 ResolveCallback(base::Value());
631 } 631 }
632 } 632 }
633 633
634 void CertificatesHandler::HandleImportPersonal(const base::ListValue* args) { 634 void CertificatesHandler::HandleImportPersonal(const base::ListValue* args) {
635 CHECK_EQ(2U, args->GetSize()); 635 CHECK_EQ(2U, args->GetSize());
636 AssignWebUICallbackId(args); 636 AssignWebUICallbackId(args);
637 CHECK(args->GetBoolean(1, &use_hardware_backed_)); 637 CHECK(args->GetBoolean(1, &use_hardware_backed_));
638 638
639 ui::SelectFileDialog::FileTypeInfo file_type_info; 639 ui::SelectFileDialog::FileTypeInfo file_type_info;
640 file_type_info.extensions.resize(1); 640 file_type_info.extensions.resize(1);
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 // We do this by checking the value of |use_hardware_backed_| which is set 736 // We do this by checking the value of |use_hardware_backed_| which is set
737 // to true if importing into a hardware module. Currently, this only happens 737 // to true if importing into a hardware module. Currently, this only happens
738 // for Chrome OS when the "Import and Bind" option is chosen. 738 // for Chrome OS when the "Import and Bind" option is chosen.
739 bool is_extractable = !use_hardware_backed_; 739 bool is_extractable = !use_hardware_backed_;
740 int result = certificate_manager_model_->ImportFromPKCS12( 740 int result = certificate_manager_model_->ImportFromPKCS12(
741 slot_.get(), file_data_, password_, is_extractable); 741 slot_.get(), file_data_, password_, is_extractable);
742 ImportExportCleanup(); 742 ImportExportCleanup();
743 int string_id; 743 int string_id;
744 switch (result) { 744 switch (result) {
745 case net::OK: 745 case net::OK:
746 ResolveCallback(*base::Value::CreateNullValue()); 746 ResolveCallback(base::Value());
747 return; 747 return;
748 case net::ERR_PKCS12_IMPORT_BAD_PASSWORD: 748 case net::ERR_PKCS12_IMPORT_BAD_PASSWORD:
749 // TODO(mattm): if the error was a bad password, we should reshow the 749 // TODO(mattm): if the error was a bad password, we should reshow the
750 // password dialog after the user dismisses the error dialog. 750 // password dialog after the user dismisses the error dialog.
751 string_id = IDS_SETTINGS_CERTIFICATE_MANAGER_BAD_PASSWORD; 751 string_id = IDS_SETTINGS_CERTIFICATE_MANAGER_BAD_PASSWORD;
752 break; 752 break;
753 case net::ERR_PKCS12_IMPORT_INVALID_MAC: 753 case net::ERR_PKCS12_IMPORT_INVALID_MAC:
754 string_id = IDS_SETTINGS_CERTIFICATE_MANAGER_IMPORT_INVALID_MAC; 754 string_id = IDS_SETTINGS_CERTIFICATE_MANAGER_IMPORT_INVALID_MAC;
755 break; 755 break;
756 case net::ERR_PKCS12_IMPORT_INVALID_FILE: 756 case net::ERR_PKCS12_IMPORT_INVALID_FILE:
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
843 l10n_util::GetStringUTF8( 843 l10n_util::GetStringUTF8(
844 IDS_SETTINGS_CERTIFICATE_MANAGER_SERVER_IMPORT_ERROR_TITLE), 844 IDS_SETTINGS_CERTIFICATE_MANAGER_SERVER_IMPORT_ERROR_TITLE),
845 l10n_util::GetStringUTF8( 845 l10n_util::GetStringUTF8(
846 IDS_SETTINGS_CERTIFICATE_MANAGER_UNKNOWN_ERROR)); 846 IDS_SETTINGS_CERTIFICATE_MANAGER_UNKNOWN_ERROR));
847 } else if (!not_imported.empty()) { 847 } else if (!not_imported.empty()) {
848 RejectCallbackWithImportError( 848 RejectCallbackWithImportError(
849 l10n_util::GetStringUTF8( 849 l10n_util::GetStringUTF8(
850 IDS_SETTINGS_CERTIFICATE_MANAGER_SERVER_IMPORT_ERROR_TITLE), 850 IDS_SETTINGS_CERTIFICATE_MANAGER_SERVER_IMPORT_ERROR_TITLE),
851 not_imported); 851 not_imported);
852 } else { 852 } else {
853 ResolveCallback(*base::Value::CreateNullValue()); 853 ResolveCallback(base::Value());
854 } 854 }
855 ImportExportCleanup(); 855 ImportExportCleanup();
856 } 856 }
857 857
858 void CertificatesHandler::HandleImportCA(const base::ListValue* args) { 858 void CertificatesHandler::HandleImportCA(const base::ListValue* args) {
859 CHECK_EQ(1U, args->GetSize()); 859 CHECK_EQ(1U, args->GetSize());
860 AssignWebUICallbackId(args); 860 AssignWebUICallbackId(args);
861 861
862 select_file_dialog_ = ui::SelectFileDialog::Create( 862 select_file_dialog_ = ui::SelectFileDialog::Create(
863 this, new ChromeSelectFilePolicy(web_ui()->GetWebContents())); 863 this, new ChromeSelectFilePolicy(web_ui()->GetWebContents()));
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
935 l10n_util::GetStringUTF8( 935 l10n_util::GetStringUTF8(
936 IDS_SETTINGS_CERTIFICATE_MANAGER_CA_IMPORT_ERROR_TITLE), 936 IDS_SETTINGS_CERTIFICATE_MANAGER_CA_IMPORT_ERROR_TITLE),
937 l10n_util::GetStringUTF8( 937 l10n_util::GetStringUTF8(
938 IDS_SETTINGS_CERTIFICATE_MANAGER_UNKNOWN_ERROR)); 938 IDS_SETTINGS_CERTIFICATE_MANAGER_UNKNOWN_ERROR));
939 } else if (!not_imported.empty()) { 939 } else if (!not_imported.empty()) {
940 RejectCallbackWithImportError( 940 RejectCallbackWithImportError(
941 l10n_util::GetStringUTF8( 941 l10n_util::GetStringUTF8(
942 IDS_SETTINGS_CERTIFICATE_MANAGER_CA_IMPORT_ERROR_TITLE), 942 IDS_SETTINGS_CERTIFICATE_MANAGER_CA_IMPORT_ERROR_TITLE),
943 not_imported); 943 not_imported);
944 } else { 944 } else {
945 ResolveCallback(*base::Value::CreateNullValue()); 945 ResolveCallback(base::Value());
946 } 946 }
947 ImportExportCleanup(); 947 ImportExportCleanup();
948 } 948 }
949 949
950 void CertificatesHandler::HandleExportCertificate(const base::ListValue* args) { 950 void CertificatesHandler::HandleExportCertificate(const base::ListValue* args) {
951 net::X509Certificate* cert = cert_id_map_->CallbackArgsToCert(args); 951 net::X509Certificate* cert = cert_id_map_->CallbackArgsToCert(args);
952 if (!cert) 952 if (!cert)
953 return; 953 return;
954 ShowCertExportDialog(web_ui()->GetWebContents(), GetParentWindow(), cert); 954 ShowCertExportDialog(web_ui()->GetWebContents(), GetParentWindow(), cert);
955 } 955 }
956 956
957 void CertificatesHandler::HandleDeleteCertificate(const base::ListValue* args) { 957 void CertificatesHandler::HandleDeleteCertificate(const base::ListValue* args) {
958 CHECK_EQ(2U, args->GetSize()); 958 CHECK_EQ(2U, args->GetSize());
959 AssignWebUICallbackId(args); 959 AssignWebUICallbackId(args);
960 std::string node_id; 960 std::string node_id;
961 CHECK(args->GetString(1, &node_id)); 961 CHECK(args->GetString(1, &node_id));
962 962
963 net::X509Certificate* cert = cert_id_map_->IdToCert(node_id); 963 net::X509Certificate* cert = cert_id_map_->IdToCert(node_id);
964 CHECK(cert); 964 CHECK(cert);
965 965
966 bool result = certificate_manager_model_->Delete(cert); 966 bool result = certificate_manager_model_->Delete(cert);
967 if (!result) { 967 if (!result) {
968 // TODO(mattm): better error messages? 968 // TODO(mattm): better error messages?
969 RejectCallbackWithError( 969 RejectCallbackWithError(
970 l10n_util::GetStringUTF8( 970 l10n_util::GetStringUTF8(
971 IDS_SETTINGS_CERTIFICATE_MANAGER_DELETE_CERT_ERROR_TITLE), 971 IDS_SETTINGS_CERTIFICATE_MANAGER_DELETE_CERT_ERROR_TITLE),
972 l10n_util::GetStringUTF8( 972 l10n_util::GetStringUTF8(
973 IDS_SETTINGS_CERTIFICATE_MANAGER_UNKNOWN_ERROR)); 973 IDS_SETTINGS_CERTIFICATE_MANAGER_UNKNOWN_ERROR));
974 } else { 974 } else {
975 ResolveCallback(*base::Value::CreateNullValue()); 975 ResolveCallback(base::Value());
976 } 976 }
977 } 977 }
978 978
979 void CertificatesHandler::OnCertificateManagerModelCreated( 979 void CertificatesHandler::OnCertificateManagerModelCreated(
980 std::unique_ptr<CertificateManagerModel> model) { 980 std::unique_ptr<CertificateManagerModel> model) {
981 certificate_manager_model_ = std::move(model); 981 certificate_manager_model_ = std::move(model);
982 CertificateManagerModelReady(); 982 CertificateManagerModelReady();
983 } 983 }
984 984
985 void CertificatesHandler::CertificateManagerModelReady() { 985 void CertificatesHandler::CertificateManagerModelReady() {
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
1138 error_info->Set(kCertificateErrors, 1138 error_info->Set(kCertificateErrors,
1139 base::WrapUnique(cert_error_list.release())); 1139 base::WrapUnique(cert_error_list.release()));
1140 RejectCallback(*error_info); 1140 RejectCallback(*error_info);
1141 } 1141 }
1142 1142
1143 gfx::NativeWindow CertificatesHandler::GetParentWindow() const { 1143 gfx::NativeWindow CertificatesHandler::GetParentWindow() const {
1144 return web_ui()->GetWebContents()->GetTopLevelNativeWindow(); 1144 return web_ui()->GetWebContents()->GetTopLevelNativeWindow();
1145 } 1145 }
1146 1146
1147 } // namespace settings 1147 } // namespace settings
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/settings/about_handler.cc ('k') | chrome/browser/ui/webui/settings/on_startup_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698