Chromium Code Reviews| Index: chrome/browser/ui/webui/net_internals/net_internals_ui.cc |
| diff --git a/chrome/browser/ui/webui/net_internals/net_internals_ui.cc b/chrome/browser/ui/webui/net_internals/net_internals_ui.cc |
| index 621b78ad6e56e6b78936b766a7140c818d70738b..868385220652dcb0d0ff88c5bb27a3422d7a15b0 100644 |
| --- a/chrome/browser/ui/webui/net_internals/net_internals_ui.cc |
| +++ b/chrome/browser/ui/webui/net_internals/net_internals_ui.cc |
| @@ -257,6 +257,13 @@ class NetInternalsMessageHandler |
| void ImportONCFileToNSSDB(const std::string& onc_blob, |
| const std::string& passcode, |
| net::NSSCertDatabase* nssdb); |
| + |
| + // Called back by the CertificateImporter when a certificate import finished. |
| + // |error| contains earlier errors during this import. |
|
eroman
2014/09/18 18:35:13
|error| --> |previous_error|
pneubeck (no reviews)
2014/09/18 18:52:02
Done.
|
| + void OnCertificatesImported( |
| + const std::string& previous_error, |
| + bool success, |
| + const net::CertificateList& onc_trusted_certificates); |
| #endif |
| private: |
| @@ -1407,38 +1414,54 @@ void NetInternalsMessageHandler::ImportONCFileToNSSDB( |
| const std::string& onc_blob, |
| const std::string& passcode, |
| net::NSSCertDatabase* nssdb) { |
| - std::string error; |
| user_manager::User* user = chromeos::ProfileHelper::Get()->GetUserByProfile( |
| Profile::FromWebUI(web_ui())); |
| - if (user) { |
| - onc::ONCSource onc_source = onc::ONC_SOURCE_USER_IMPORT; |
| - |
| - base::ListValue network_configs; |
| - base::DictionaryValue global_network_config; |
| - base::ListValue certificates; |
| - if (!chromeos::onc::ParseAndValidateOncForImport(onc_blob, |
| - onc_source, |
| - passcode, |
| - &network_configs, |
| - &global_network_config, |
| - &certificates)) { |
| - error = "Errors occurred during the ONC parsing. "; |
| - } |
| - |
| - chromeos::onc::CertificateImporterImpl cert_importer(nssdb); |
| - if (!cert_importer.ImportCertificates(certificates, onc_source, NULL)) |
| - error += "Some certificates couldn't be imported. "; |
| + if (!user) { |
| + std::string error = "User not found."; |
| + LOG(ERROR) << error; |
|
eroman
2014/09/18 18:35:13
Is logging necessary or useful here? (given that t
pneubeck (no reviews)
2014/09/18 18:52:02
Done.
|
| + SendJavascriptCommand("receivedONCFileParse", new base::StringValue(error)); |
| + return; |
| + } |
| - std::string network_error; |
| - chromeos::onc::ImportNetworksForUser(user, network_configs, &network_error); |
| - if (!network_error.empty()) |
| - error += network_error; |
| - } else { |
| - error = "User not found."; |
| + std::string error; |
| + onc::ONCSource onc_source = onc::ONC_SOURCE_USER_IMPORT; |
| + base::ListValue network_configs; |
| + base::DictionaryValue global_network_config; |
| + base::ListValue certificates; |
| + if (!chromeos::onc::ParseAndValidateOncForImport(onc_blob, |
| + onc_source, |
| + passcode, |
| + &network_configs, |
| + &global_network_config, |
| + &certificates)) { |
| + error = "Errors occurred during the ONC parsing. "; |
| } |
| - LOG_IF(ERROR, !error.empty()) << error; |
| + std::string network_error; |
| + chromeos::onc::ImportNetworksForUser(user, network_configs, &network_error); |
| + if (!network_error.empty()) |
| + error += network_error; |
| + |
| + chromeos::onc::CertificateImporterImpl cert_importer( |
| + BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO), nssdb); |
| + cert_importer.ImportCertificates( |
| + certificates, |
| + onc_source, |
| + base::Bind(&NetInternalsMessageHandler::OnCertificatesImported, |
| + AsWeakPtr(), |
| + error)); |
| +} |
| + |
| +void NetInternalsMessageHandler::OnCertificatesImported( |
| + const std::string& previous_error, |
| + bool success, |
| + const net::CertificateList& /* unused onc_trusted_certificates */) { |
| + std::string error = previous_error; |
| + if (!success) |
| + error += "Some certificates couldn't be imported. "; |
| + |
| + LOG(ERROR) << error; |
|
eroman
2014/09/18 18:35:13
Same comment about logging.
pneubeck (no reviews)
2014/09/18 18:52:02
Done.
|
| SendJavascriptCommand("receivedONCFileParse", new base::StringValue(error)); |
| } |