OLD | NEW |
---|---|
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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
69 #include "net/proxy/proxy_service.h" | 69 #include "net/proxy/proxy_service.h" |
70 #include "net/url_request/url_request_context.h" | 70 #include "net/url_request/url_request_context.h" |
71 #include "net/url_request/url_request_context_getter.h" | 71 #include "net/url_request/url_request_context_getter.h" |
72 | 72 |
73 #if defined(OS_CHROMEOS) | 73 #if defined(OS_CHROMEOS) |
74 #include "chrome/browser/chromeos/file_manager/filesystem_api_util.h" | 74 #include "chrome/browser/chromeos/file_manager/filesystem_api_util.h" |
75 #include "chrome/browser/chromeos/net/onc_utils.h" | 75 #include "chrome/browser/chromeos/net/onc_utils.h" |
76 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 76 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
77 #include "chrome/browser/chromeos/system/syslogs_provider.h" | 77 #include "chrome/browser/chromeos/system/syslogs_provider.h" |
78 #include "chrome/browser/chromeos/system_logs/debug_log_writer.h" | 78 #include "chrome/browser/chromeos/system_logs/debug_log_writer.h" |
79 #include "chrome/browser/net/nss_context.h" | 79 #include "chrome/browser/net/cert_database_service_factory.h" |
80 #include "chromeos/dbus/dbus_thread_manager.h" | 80 #include "chromeos/dbus/dbus_thread_manager.h" |
81 #include "chromeos/dbus/debug_daemon_client.h" | 81 #include "chromeos/dbus/debug_daemon_client.h" |
82 #include "chromeos/network/onc/onc_certificate_importer_impl.h" | 82 #include "chromeos/network/onc/onc_certificate_importer_impl.h" |
83 #include "chromeos/network/onc/onc_utils.h" | 83 #include "chromeos/network/onc/onc_utils.h" |
84 #include "components/cert_database/public/cert_database_service.h" | |
84 #include "components/user_manager/user.h" | 85 #include "components/user_manager/user.h" |
85 #endif | 86 #endif |
86 | 87 |
87 #if defined(OS_WIN) | 88 #if defined(OS_WIN) |
88 #include "chrome/browser/net/service_providers_win.h" | 89 #include "chrome/browser/net/service_providers_win.h" |
89 #endif | 90 #endif |
90 | 91 |
91 #if defined(ENABLE_EXTENSIONS) | 92 #if defined(ENABLE_EXTENSIONS) |
92 #include "chrome/browser/extensions/extension_service.h" | 93 #include "chrome/browser/extensions/extension_service.h" |
93 #include "chrome/browser/ui/webui/extensions/extension_basic_info.h" | 94 #include "chrome/browser/ui/webui/extensions/extension_basic_info.h" |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
243 void OnRefreshSystemLogs(const base::ListValue* list); | 244 void OnRefreshSystemLogs(const base::ListValue* list); |
244 void OnGetSystemLog(const base::ListValue* list); | 245 void OnGetSystemLog(const base::ListValue* list); |
245 void OnImportONCFile(const base::ListValue* list); | 246 void OnImportONCFile(const base::ListValue* list); |
246 void OnStoreDebugLogs(const base::ListValue* list); | 247 void OnStoreDebugLogs(const base::ListValue* list); |
247 void OnStoreDebugLogsCompleted(const base::FilePath& log_path, | 248 void OnStoreDebugLogsCompleted(const base::FilePath& log_path, |
248 bool succeeded); | 249 bool succeeded); |
249 void OnSetNetworkDebugMode(const base::ListValue* list); | 250 void OnSetNetworkDebugMode(const base::ListValue* list); |
250 void OnSetNetworkDebugModeCompleted(const std::string& subsystem, | 251 void OnSetNetworkDebugModeCompleted(const std::string& subsystem, |
251 bool succeeded); | 252 bool succeeded); |
252 | 253 |
253 // Callback to |GetNSSCertDatabaseForProfile| used to retrieve the database | |
254 // to which user's ONC defined certificates should be imported. | |
255 // It parses and imports |onc_blob|. | |
256 void ImportONCFileToNSSDB(const std::string& onc_blob, | |
257 const std::string& passcode, | |
258 net::NSSCertDatabase* nssdb); | |
259 | |
260 // Called back by the CertificateImporter when a certificate import finished. | 254 // Called back by the CertificateImporter when a certificate import finished. |
261 // |previous_error| contains earlier errors during this import. | 255 // |previous_error| contains earlier errors during this import. |
262 void OnCertificatesImported( | 256 void OnCertificatesImported( |
263 const std::string& previous_error, | 257 const std::string& previous_error, |
264 bool success, | 258 bool success, |
265 const net::CertificateList& onc_trusted_certificates); | 259 const net::CertificateList& onc_trusted_certificates); |
266 #endif | 260 #endif |
267 | 261 |
268 private: | 262 private: |
269 class IOThreadImpl; | 263 class IOThreadImpl; |
(...skipping 1132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1402 syslogs_getter_->DeleteSystemLogs(); | 1396 syslogs_getter_->DeleteSystemLogs(); |
1403 syslogs_getter_->LoadSystemLogs(); | 1397 syslogs_getter_->LoadSystemLogs(); |
1404 } | 1398 } |
1405 | 1399 |
1406 void NetInternalsMessageHandler::OnGetSystemLog( | 1400 void NetInternalsMessageHandler::OnGetSystemLog( |
1407 const base::ListValue* list) { | 1401 const base::ListValue* list) { |
1408 DCHECK(syslogs_getter_.get()); | 1402 DCHECK(syslogs_getter_.get()); |
1409 syslogs_getter_->RequestSystemLog(list); | 1403 syslogs_getter_->RequestSystemLog(list); |
1410 } | 1404 } |
1411 | 1405 |
1412 void NetInternalsMessageHandler::ImportONCFileToNSSDB( | 1406 void NetInternalsMessageHandler::OnImportONCFile(const base::ListValue* list) { |
1413 const std::string& onc_blob, | 1407 std::string onc_blob; |
1414 const std::string& passcode, | 1408 std::string passcode; |
1415 net::NSSCertDatabase* nssdb) { | 1409 if (list->GetSize() != 2 || !list->GetString(0, &onc_blob) || |
1410 !list->GetString(1, &passcode)) { | |
1411 NOTREACHED(); | |
1412 } | |
1413 | |
1416 user_manager::User* user = chromeos::ProfileHelper::Get()->GetUserByProfile( | 1414 user_manager::User* user = chromeos::ProfileHelper::Get()->GetUserByProfile( |
1417 Profile::FromWebUI(web_ui())); | 1415 Profile::FromWebUI(web_ui())); |
1418 | 1416 |
1419 if (!user) { | 1417 if (!user) { |
1420 std::string error = "User not found."; | 1418 std::string error = "User not found."; |
1421 SendJavascriptCommand("receivedONCFileParse", new base::StringValue(error)); | 1419 SendJavascriptCommand("receivedONCFileParse", new base::StringValue(error)); |
1422 return; | 1420 return; |
1423 } | 1421 } |
1424 | 1422 |
1425 std::string error; | 1423 std::string error; |
1426 onc::ONCSource onc_source = onc::ONC_SOURCE_USER_IMPORT; | 1424 onc::ONCSource onc_source = onc::ONC_SOURCE_USER_IMPORT; |
1427 base::ListValue network_configs; | 1425 base::ListValue network_configs; |
1428 base::DictionaryValue global_network_config; | 1426 base::DictionaryValue global_network_config; |
1429 base::ListValue certificates; | 1427 base::ListValue certificates; |
1430 if (!chromeos::onc::ParseAndValidateOncForImport(onc_blob, | 1428 if (!chromeos::onc::ParseAndValidateOncForImport(onc_blob, |
1431 onc_source, | 1429 onc_source, |
1432 passcode, | 1430 passcode, |
1433 &network_configs, | 1431 &network_configs, |
1434 &global_network_config, | 1432 &global_network_config, |
1435 &certificates)) { | 1433 &certificates)) { |
1436 error = "Errors occurred during the ONC parsing. "; | 1434 error = "Errors occurred during the ONC parsing. "; |
1437 } | 1435 } |
1438 | 1436 |
1439 std::string network_error; | 1437 std::string network_error; |
1440 chromeos::onc::ImportNetworksForUser(user, network_configs, &network_error); | 1438 chromeos::onc::ImportNetworksForUser(user, network_configs, &network_error); |
1441 if (!network_error.empty()) | 1439 if (!network_error.empty()) |
1442 error += network_error; | 1440 error += network_error; |
1443 | 1441 |
1442 cert_database::CertDatabaseService* cert_service = | |
1443 cert_database::CertDatabaseServiceFactory::GetForBrowserContext( | |
1444 web_ui()->GetWebContents()->GetBrowserContext()); | |
1444 chromeos::onc::CertificateImporterImpl cert_importer( | 1445 chromeos::onc::CertificateImporterImpl cert_importer( |
1445 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO), nssdb); | 1446 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO), |
1447 cert_service->GetIOPart()); | |
Joao da Silva
2014/10/30 09:48:01
May be NULL
pneubeck (no reviews)
2014/11/05 14:53:36
Done.
| |
1446 cert_importer.ImportCertificates( | 1448 cert_importer.ImportCertificates( |
1447 certificates, | 1449 certificates, |
1448 onc_source, | 1450 onc_source, |
1449 base::Bind(&NetInternalsMessageHandler::OnCertificatesImported, | 1451 base::Bind(&NetInternalsMessageHandler::OnCertificatesImported, |
1450 AsWeakPtr(), | 1452 AsWeakPtr(), |
1451 error)); | 1453 error)); |
1452 } | 1454 } |
1453 | 1455 |
1454 void NetInternalsMessageHandler::OnCertificatesImported( | 1456 void NetInternalsMessageHandler::OnCertificatesImported( |
1455 const std::string& previous_error, | 1457 const std::string& previous_error, |
1456 bool success, | 1458 bool success, |
1457 const net::CertificateList& /* unused onc_trusted_certificates */) { | 1459 const net::CertificateList& /* unused onc_trusted_certificates */) { |
1458 std::string error = previous_error; | 1460 std::string error = previous_error; |
1459 if (!success) | 1461 if (!success) |
1460 error += "Some certificates couldn't be imported. "; | 1462 error += "Some certificates couldn't be imported. "; |
1461 | 1463 |
1462 SendJavascriptCommand("receivedONCFileParse", new base::StringValue(error)); | 1464 SendJavascriptCommand("receivedONCFileParse", new base::StringValue(error)); |
1463 } | 1465 } |
1464 | 1466 |
1465 void NetInternalsMessageHandler::OnImportONCFile( | |
1466 const base::ListValue* list) { | |
1467 std::string onc_blob; | |
1468 std::string passcode; | |
1469 if (list->GetSize() != 2 || | |
1470 !list->GetString(0, &onc_blob) || | |
1471 !list->GetString(1, &passcode)) { | |
1472 NOTREACHED(); | |
1473 } | |
1474 | |
1475 GetNSSCertDatabaseForProfile( | |
1476 Profile::FromWebUI(web_ui()), | |
1477 base::Bind(&NetInternalsMessageHandler::ImportONCFileToNSSDB, AsWeakPtr(), | |
1478 onc_blob, passcode)); | |
1479 } | |
1480 | |
1481 void NetInternalsMessageHandler::OnStoreDebugLogs(const base::ListValue* list) { | 1467 void NetInternalsMessageHandler::OnStoreDebugLogs(const base::ListValue* list) { |
1482 DCHECK(list); | 1468 DCHECK(list); |
1483 | 1469 |
1484 SendJavascriptCommand("receivedStoreDebugLogs", | 1470 SendJavascriptCommand("receivedStoreDebugLogs", |
1485 new base::StringValue("Creating log file...")); | 1471 new base::StringValue("Creating log file...")); |
1486 Profile* profile = Profile::FromWebUI(web_ui()); | 1472 Profile* profile = Profile::FromWebUI(web_ui()); |
1487 const DownloadPrefs* const prefs = DownloadPrefs::FromBrowserContext(profile); | 1473 const DownloadPrefs* const prefs = DownloadPrefs::FromBrowserContext(profile); |
1488 base::FilePath path = prefs->DownloadPath(); | 1474 base::FilePath path = prefs->DownloadPath(); |
1489 if (file_manager::util::IsUnderNonNativeLocalPath(profile, path)) | 1475 if (file_manager::util::IsUnderNonNativeLocalPath(profile, path)) |
1490 path = prefs->GetDefaultDownloadDirectoryForProfile(); | 1476 path = prefs->GetDefaultDownloadDirectoryForProfile(); |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1724 } | 1710 } |
1725 | 1711 |
1726 NetInternalsUI::NetInternalsUI(content::WebUI* web_ui) | 1712 NetInternalsUI::NetInternalsUI(content::WebUI* web_ui) |
1727 : WebUIController(web_ui) { | 1713 : WebUIController(web_ui) { |
1728 web_ui->AddMessageHandler(new NetInternalsMessageHandler()); | 1714 web_ui->AddMessageHandler(new NetInternalsMessageHandler()); |
1729 | 1715 |
1730 // Set up the chrome://net-internals/ source. | 1716 // Set up the chrome://net-internals/ source. |
1731 Profile* profile = Profile::FromWebUI(web_ui); | 1717 Profile* profile = Profile::FromWebUI(web_ui); |
1732 content::WebUIDataSource::Add(profile, CreateNetInternalsHTMLSource()); | 1718 content::WebUIDataSource::Add(profile, CreateNetInternalsHTMLSource()); |
1733 } | 1719 } |
OLD | NEW |