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

Side by Side Diff: chrome/browser/ui/webui/net_internals/net_internals_ui.cc

Issue 580283005: Revert of Make ONCCertificateImporter async. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@nss_util_deadcode
Patch Set: Created 6 years, 3 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/net_internals/net_internals_ui.h" 5 #include "chrome/browser/ui/webui/net_internals/net_internals_ui.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <list> 8 #include <list>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 void OnSetNetworkDebugMode(const base::ListValue* list); 250 void OnSetNetworkDebugMode(const base::ListValue* list);
251 void OnSetNetworkDebugModeCompleted(const std::string& subsystem, 251 void OnSetNetworkDebugModeCompleted(const std::string& subsystem,
252 bool succeeded); 252 bool succeeded);
253 253
254 // Callback to |GetNSSCertDatabaseForProfile| used to retrieve the database 254 // Callback to |GetNSSCertDatabaseForProfile| used to retrieve the database
255 // to which user's ONC defined certificates should be imported. 255 // to which user's ONC defined certificates should be imported.
256 // It parses and imports |onc_blob|. 256 // It parses and imports |onc_blob|.
257 void ImportONCFileToNSSDB(const std::string& onc_blob, 257 void ImportONCFileToNSSDB(const std::string& onc_blob,
258 const std::string& passcode, 258 const std::string& passcode,
259 net::NSSCertDatabase* nssdb); 259 net::NSSCertDatabase* nssdb);
260
261 // Called back by the CertificateImporter when a certificate import finished.
262 // |previous_error| contains earlier errors during this import.
263 void OnCertificatesImported(
264 const std::string& previous_error,
265 bool success,
266 const net::CertificateList& onc_trusted_certificates);
267 #endif 260 #endif
268 261
269 private: 262 private:
270 class IOThreadImpl; 263 class IOThreadImpl;
271 264
272 #if defined(OS_CHROMEOS) 265 #if defined(OS_CHROMEOS)
273 // Class that is used for getting network related ChromeOS logs. 266 // Class that is used for getting network related ChromeOS logs.
274 // Logs are fetched from ChromeOS libcros on user request, and only when we 267 // Logs are fetched from ChromeOS libcros on user request, and only when we
275 // don't yet have a copy of logs. If a copy is present, we send back data from 268 // don't yet have a copy of logs. If a copy is present, we send back data from
276 // it, else we save request and answer to it when we get logs from libcros. 269 // it, else we save request and answer to it when we get logs from libcros.
(...skipping 1130 matching lines...) Expand 10 before | Expand all | Expand 10 after
1407 void NetInternalsMessageHandler::OnGetSystemLog( 1400 void NetInternalsMessageHandler::OnGetSystemLog(
1408 const base::ListValue* list) { 1401 const base::ListValue* list) {
1409 DCHECK(syslogs_getter_.get()); 1402 DCHECK(syslogs_getter_.get());
1410 syslogs_getter_->RequestSystemLog(list); 1403 syslogs_getter_->RequestSystemLog(list);
1411 } 1404 }
1412 1405
1413 void NetInternalsMessageHandler::ImportONCFileToNSSDB( 1406 void NetInternalsMessageHandler::ImportONCFileToNSSDB(
1414 const std::string& onc_blob, 1407 const std::string& onc_blob,
1415 const std::string& passcode, 1408 const std::string& passcode,
1416 net::NSSCertDatabase* nssdb) { 1409 net::NSSCertDatabase* nssdb) {
1410 std::string error;
1417 user_manager::User* user = chromeos::ProfileHelper::Get()->GetUserByProfile( 1411 user_manager::User* user = chromeos::ProfileHelper::Get()->GetUserByProfile(
1418 Profile::FromWebUI(web_ui())); 1412 Profile::FromWebUI(web_ui()));
1419 1413
1420 if (!user) { 1414 if (user) {
1421 std::string error = "User not found."; 1415 onc::ONCSource onc_source = onc::ONC_SOURCE_USER_IMPORT;
1422 SendJavascriptCommand("receivedONCFileParse", new base::StringValue(error)); 1416
1423 return; 1417 base::ListValue network_configs;
1418 base::DictionaryValue global_network_config;
1419 base::ListValue certificates;
1420 if (!chromeos::onc::ParseAndValidateOncForImport(onc_blob,
1421 onc_source,
1422 passcode,
1423 &network_configs,
1424 &global_network_config,
1425 &certificates)) {
1426 error = "Errors occurred during the ONC parsing. ";
1427 }
1428
1429 chromeos::onc::CertificateImporterImpl cert_importer(nssdb);
1430 if (!cert_importer.ImportCertificates(certificates, onc_source, NULL))
1431 error += "Some certificates couldn't be imported. ";
1432
1433 std::string network_error;
1434 chromeos::onc::ImportNetworksForUser(user, network_configs, &network_error);
1435 if (!network_error.empty())
1436 error += network_error;
1437 } else {
1438 error = "User not found.";
1424 } 1439 }
1425 1440
1426 std::string error; 1441 LOG_IF(ERROR, !error.empty()) << error;
1427 onc::ONCSource onc_source = onc::ONC_SOURCE_USER_IMPORT;
1428 base::ListValue network_configs;
1429 base::DictionaryValue global_network_config;
1430 base::ListValue certificates;
1431 if (!chromeos::onc::ParseAndValidateOncForImport(onc_blob,
1432 onc_source,
1433 passcode,
1434 &network_configs,
1435 &global_network_config,
1436 &certificates)) {
1437 error = "Errors occurred during the ONC parsing. ";
1438 }
1439
1440 std::string network_error;
1441 chromeos::onc::ImportNetworksForUser(user, network_configs, &network_error);
1442 if (!network_error.empty())
1443 error += network_error;
1444
1445 chromeos::onc::CertificateImporterImpl cert_importer(
1446 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO), nssdb);
1447 cert_importer.ImportCertificates(
1448 certificates,
1449 onc_source,
1450 base::Bind(&NetInternalsMessageHandler::OnCertificatesImported,
1451 AsWeakPtr(),
1452 error));
1453 }
1454
1455 void NetInternalsMessageHandler::OnCertificatesImported(
1456 const std::string& previous_error,
1457 bool success,
1458 const net::CertificateList& /* unused onc_trusted_certificates */) {
1459 std::string error = previous_error;
1460 if (!success)
1461 error += "Some certificates couldn't be imported. ";
1462
1463 SendJavascriptCommand("receivedONCFileParse", new base::StringValue(error)); 1442 SendJavascriptCommand("receivedONCFileParse", new base::StringValue(error));
1464 } 1443 }
1465 1444
1466 void NetInternalsMessageHandler::OnImportONCFile( 1445 void NetInternalsMessageHandler::OnImportONCFile(
1467 const base::ListValue* list) { 1446 const base::ListValue* list) {
1468 std::string onc_blob; 1447 std::string onc_blob;
1469 std::string passcode; 1448 std::string passcode;
1470 if (list->GetSize() != 2 || 1449 if (list->GetSize() != 2 ||
1471 !list->GetString(0, &onc_blob) || 1450 !list->GetString(0, &onc_blob) ||
1472 !list->GetString(1, &passcode)) { 1451 !list->GetString(1, &passcode)) {
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
1730 } 1709 }
1731 1710
1732 NetInternalsUI::NetInternalsUI(content::WebUI* web_ui) 1711 NetInternalsUI::NetInternalsUI(content::WebUI* web_ui)
1733 : WebUIController(web_ui) { 1712 : WebUIController(web_ui) {
1734 web_ui->AddMessageHandler(new NetInternalsMessageHandler()); 1713 web_ui->AddMessageHandler(new NetInternalsMessageHandler());
1735 1714
1736 // Set up the chrome://net-internals/ source. 1715 // Set up the chrome://net-internals/ source.
1737 Profile* profile = Profile::FromWebUI(web_ui); 1716 Profile* profile = Profile::FromWebUI(web_ui);
1738 content::WebUIDataSource::Add(profile, CreateNetInternalsHTMLSource()); 1717 content::WebUIDataSource::Add(profile, CreateNetInternalsHTMLSource());
1739 } 1718 }
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/policy/user_network_configuration_updater.cc ('k') | chromeos/chromeos.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698