Chromium Code Reviews| Index: chrome/browser/ui/webui/options/certificate_manager_handler.cc |
| diff --git a/chrome/browser/ui/webui/options/certificate_manager_handler.cc b/chrome/browser/ui/webui/options/certificate_manager_handler.cc |
| index cf03f83b97bb1c5e7a01363601e52618cea1bb7f..e703731d2d6b496c66cb931a202628bd394fb390 100644 |
| --- a/chrome/browser/ui/webui/options/certificate_manager_handler.cc |
| +++ b/chrome/browser/ui/webui/options/certificate_manager_handler.cc |
| @@ -709,8 +709,9 @@ void CertificateManagerHandler::StartImportPersonal( |
| } |
| file_type_info.extensions.resize(1); |
| file_type_info.extensions[0].push_back(FILE_PATH_LITERAL("p12")); |
| + file_type_info.extensions[0].push_back(FILE_PATH_LITERAL("crt")); |
| file_type_info.extension_description_overrides.push_back( |
| - l10n_util::GetStringUTF16(IDS_CERT_MANAGER_PKCS12_FILES)); |
| + l10n_util::GetStringUTF16(IDS_CERT_USAGE_SSL_CLIENT)); |
| file_type_info.include_all_files = true; |
| select_file_dialog_ = ui::SelectFileDialog::Create( |
| this, new ChromeSelectFilePolicy(web_ui()->GetWebContents())); |
| @@ -724,8 +725,17 @@ void CertificateManagerHandler::StartImportPersonal( |
| void CertificateManagerHandler::ImportPersonalFileSelected( |
| const base::FilePath& path) { |
| file_path_ = path; |
| - web_ui()->CallJavascriptFunction( |
| - "CertificateManager.importPersonalAskPassword"); |
| + if (file_path_.MatchesExtension(FILE_PATH_LITERAL(".p12"))) { |
| + web_ui()->CallJavascriptFunction( |
| + "CertificateManager.importPersonalAskPassword"); |
| + } else { |
| + password_.clear(); |
| + file_access_provider_->StartRead( |
| + file_path_, |
| + base::Bind(&CertificateManagerHandler::ImportPersonalFileRead, |
| + base::Unretained(this)), |
| + &tracker_); |
| + } |
| } |
| void CertificateManagerHandler::ImportPersonalPasswordSelected( |
| @@ -757,21 +767,42 @@ void CertificateManagerHandler::ImportPersonalFileRead( |
| file_data_ = *data; |
| - if (use_hardware_backed_) { |
| - module_ = certificate_manager_model_->cert_db()->GetPrivateModule(); |
| + if (file_path_.MatchesExtension(FILE_PATH_LITERAL(".p12"))) { |
| + if (use_hardware_backed_) { |
| + module_ = certificate_manager_model_->cert_db()->GetPrivateModule(); |
| + } else { |
| + module_ = certificate_manager_model_->cert_db()->GetPublicModule(); |
| + } |
| + |
| + net::CryptoModuleList modules; |
| + modules.push_back(module_); |
| + chrome::UnlockSlotsIfNecessary( |
| + modules, |
| + chrome::kCryptoModulePasswordCertImport, |
| + net::HostPortPair(), // unused. |
| + GetParentWindow(), |
| + base::Bind(&CertificateManagerHandler::ImportPersonalSlotUnlocked, |
| + base::Unretained(this))); |
| } else { |
|
mattm
2015/11/06 23:12:59
This case needs to do the cleanup and overlay dism
svaldez
2015/11/10 15:07:50
Done.
|
| - module_ = certificate_manager_model_->cert_db()->GetPublicModule(); |
| + int result = certificate_manager_model_->ImportUserCert(file_data_); |
| + int string_id; |
| + switch (result) { |
| + case net::OK: |
| + return; |
| + case net::ERR_NO_PRIVATE_KEY_FOR_CERT: |
| + string_id = IDS_CERT_MANAGER_IMPORT_MISSING_KEY; |
| + break; |
| + case net::ERR_CERT_INVALID: |
| + string_id = IDS_CERT_MANAGER_READ_ERROR_FORMAT; |
| + break; |
| + default: |
| + string_id = IDS_CERT_MANAGER_UNKNOWN_ERROR; |
| + break; |
| + } |
| + ShowError( |
| + l10n_util::GetStringUTF8(IDS_CERT_MANAGER_PKCS12_IMPORT_ERROR_TITLE), |
|
mattm
2015/11/06 23:13:00
same comment as above
svaldez
2015/11/10 15:07:50
Done.
|
| + l10n_util::GetStringUTF8(string_id)); |
| } |
| - |
| - net::CryptoModuleList modules; |
| - modules.push_back(module_); |
| - chrome::UnlockSlotsIfNecessary( |
| - modules, |
| - chrome::kCryptoModulePasswordCertImport, |
| - net::HostPortPair(), // unused. |
| - GetParentWindow(), |
| - base::Bind(&CertificateManagerHandler::ImportPersonalSlotUnlocked, |
| - base::Unretained(this))); |
| } |
| void CertificateManagerHandler::ImportPersonalSlotUnlocked() { |