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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
76 #include "net/proxy/proxy_service.h" | 76 #include "net/proxy/proxy_service.h" |
77 #include "net/url_request/url_request_context.h" | 77 #include "net/url_request/url_request_context.h" |
78 #include "net/url_request/url_request_context_getter.h" | 78 #include "net/url_request/url_request_context_getter.h" |
79 #include "ui/base/resource/resource_bundle.h" | 79 #include "ui/base/resource/resource_bundle.h" |
80 | 80 |
81 #if defined(OS_CHROMEOS) | 81 #if defined(OS_CHROMEOS) |
82 #include "chrome/browser/chromeos/login/user.h" | 82 #include "chrome/browser/chromeos/login/user.h" |
83 #include "chrome/browser/chromeos/login/user_manager.h" | 83 #include "chrome/browser/chromeos/login/user_manager.h" |
84 #include "chrome/browser/chromeos/net/onc_utils.h" | 84 #include "chrome/browser/chromeos/net/onc_utils.h" |
85 #include "chrome/browser/chromeos/system/syslogs_provider.h" | 85 #include "chrome/browser/chromeos/system/syslogs_provider.h" |
86 #include "chrome/browser/net/nss_context.h" | |
86 #include "chromeos/dbus/dbus_thread_manager.h" | 87 #include "chromeos/dbus/dbus_thread_manager.h" |
87 #include "chromeos/dbus/debug_daemon_client.h" | 88 #include "chromeos/dbus/debug_daemon_client.h" |
88 #include "chromeos/network/onc/onc_certificate_importer_impl.h" | 89 #include "chromeos/network/onc/onc_certificate_importer_impl.h" |
89 #include "chromeos/network/onc/onc_utils.h" | 90 #include "chromeos/network/onc/onc_utils.h" |
90 #endif | 91 #endif |
91 #if defined(OS_WIN) | 92 #if defined(OS_WIN) |
92 #include "chrome/browser/net/service_providers_win.h" | 93 #include "chrome/browser/net/service_providers_win.h" |
93 #endif | 94 #endif |
94 | 95 |
95 using base::PassPlatformFile; | 96 using base::PassPlatformFile; |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
382 #if defined(OS_CHROMEOS) | 383 #if defined(OS_CHROMEOS) |
383 void OnRefreshSystemLogs(const base::ListValue* list); | 384 void OnRefreshSystemLogs(const base::ListValue* list); |
384 void OnGetSystemLog(const base::ListValue* list); | 385 void OnGetSystemLog(const base::ListValue* list); |
385 void OnImportONCFile(const base::ListValue* list); | 386 void OnImportONCFile(const base::ListValue* list); |
386 void OnStoreDebugLogs(const base::ListValue* list); | 387 void OnStoreDebugLogs(const base::ListValue* list); |
387 void OnStoreDebugLogsCompleted(const base::FilePath& log_path, | 388 void OnStoreDebugLogsCompleted(const base::FilePath& log_path, |
388 bool succeeded); | 389 bool succeeded); |
389 void OnSetNetworkDebugMode(const base::ListValue* list); | 390 void OnSetNetworkDebugMode(const base::ListValue* list); |
390 void OnSetNetworkDebugModeCompleted(const std::string& subsystem, | 391 void OnSetNetworkDebugModeCompleted(const std::string& subsystem, |
391 bool succeeded); | 392 bool succeeded); |
393 | |
394 // Does ONC import once the NSSCertDatabase which should be used for importing | |
pneubeck (no reviews)
2014/02/05 11:03:27
nit: missing commas? ..., which ... certificates,
tbarzic
2014/02/06 01:19:42
yeah, the comment does not make much sense in the
| |
395 // certificates is fetched. | |
396 void ImportONCFileToNSSDB(const std::string& onc_blob, | |
397 const std::string& passcode, | |
398 net::NSSCertDatabase* nssdb); | |
392 #endif | 399 #endif |
393 | 400 |
394 private: | 401 private: |
395 class IOThreadImpl; | 402 class IOThreadImpl; |
396 | 403 |
397 #if defined(OS_CHROMEOS) | 404 #if defined(OS_CHROMEOS) |
398 // Class that is used for getting network related ChromeOS logs. | 405 // Class that is used for getting network related ChromeOS logs. |
399 // Logs are fetched from ChromeOS libcros on user request, and only when we | 406 // Logs are fetched from ChromeOS libcros on user request, and only when we |
400 // don't yet have a copy of logs. If a copy is present, we send back data from | 407 // don't yet have a copy of logs. If a copy is present, we send back data from |
401 // it, else we save request and answer to it when we get logs from libcros. | 408 // it, else we save request and answer to it when we get logs from libcros. |
(...skipping 1094 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1496 syslogs_getter_->DeleteSystemLogs(); | 1503 syslogs_getter_->DeleteSystemLogs(); |
1497 syslogs_getter_->LoadSystemLogs(); | 1504 syslogs_getter_->LoadSystemLogs(); |
1498 } | 1505 } |
1499 | 1506 |
1500 void NetInternalsMessageHandler::OnGetSystemLog( | 1507 void NetInternalsMessageHandler::OnGetSystemLog( |
1501 const base::ListValue* list) { | 1508 const base::ListValue* list) { |
1502 DCHECK(syslogs_getter_.get()); | 1509 DCHECK(syslogs_getter_.get()); |
1503 syslogs_getter_->RequestSystemLog(list); | 1510 syslogs_getter_->RequestSystemLog(list); |
1504 } | 1511 } |
1505 | 1512 |
1506 void NetInternalsMessageHandler::OnImportONCFile( | 1513 void NetInternalsMessageHandler::ImportONCFileToNSSDB( |
1507 const base::ListValue* list) { | 1514 const std::string& onc_blob, |
1508 std::string onc_blob; | 1515 const std::string& passcode, |
1509 std::string passcode; | 1516 net::NSSCertDatabase* nssdb) { |
1510 if (list->GetSize() != 2 || | 1517 std::string error; |
1511 !list->GetString(0, &onc_blob) || | 1518 chromeos::User* user = chromeos::UserManager::Get()->GetUserByProfile( |
1512 !list->GetString(1, &passcode)) { | 1519 Profile::FromWebUI(web_ui())); |
1513 NOTREACHED(); | |
1514 } | |
1515 | 1520 |
1516 std::string error; | |
1517 const chromeos::User* user = chromeos::UserManager::Get()->GetActiveUser(); | |
1518 if (user) { | 1521 if (user) { |
1519 onc::ONCSource onc_source = onc::ONC_SOURCE_USER_IMPORT; | 1522 onc::ONCSource onc_source = onc::ONC_SOURCE_USER_IMPORT; |
1520 | 1523 |
1521 base::ListValue network_configs; | 1524 base::ListValue network_configs; |
1522 base::DictionaryValue global_network_config; | 1525 base::DictionaryValue global_network_config; |
1523 base::ListValue certificates; | 1526 base::ListValue certificates; |
1524 if (!chromeos::onc::ParseAndValidateOncForImport(onc_blob, | 1527 if (!chromeos::onc::ParseAndValidateOncForImport(onc_blob, |
1525 onc_source, | 1528 onc_source, |
1526 passcode, | 1529 passcode, |
1527 &network_configs, | 1530 &network_configs, |
1528 &global_network_config, | 1531 &global_network_config, |
1529 &certificates)) { | 1532 &certificates)) { |
1530 error = "Errors occurred during the ONC parsing. "; | 1533 error = "Errors occurred during the ONC parsing. "; |
1531 } | 1534 } |
1532 | 1535 |
1533 chromeos::onc::CertificateImporterImpl cert_importer; | 1536 chromeos::onc::CertificateImporterImpl cert_importer; |
1534 if (!cert_importer.ImportCertificates(certificates, onc_source, NULL)) | 1537 if (!cert_importer.ImportCertificates(certificates, |
1538 onc_source, | |
1539 nssdb, | |
1540 NULL)) { | |
1535 error += "Some certificates couldn't be imported. "; | 1541 error += "Some certificates couldn't be imported. "; |
1542 } | |
1536 | 1543 |
1537 std::string network_error; | 1544 std::string network_error; |
1538 chromeos::onc::ImportNetworksForUser(user, network_configs, &network_error); | 1545 chromeos::onc::ImportNetworksForUser(user, network_configs, &network_error); |
1539 if (!network_error.empty()) | 1546 if (!network_error.empty()) |
1540 error += network_error; | 1547 error += network_error; |
1541 } else { | 1548 } else { |
1542 error = "No active user."; | 1549 error = "User not found."; |
1543 } | 1550 } |
1544 | 1551 |
1545 LOG_IF(ERROR, !error.empty()) << error; | 1552 LOG_IF(ERROR, !error.empty()) << error; |
1546 SendJavascriptCommand("receivedONCFileParse", new base::StringValue(error)); | 1553 SendJavascriptCommand("receivedONCFileParse", new base::StringValue(error)); |
1547 } | 1554 } |
1548 | 1555 |
1556 void NetInternalsMessageHandler::OnImportONCFile( | |
1557 const base::ListValue* list) { | |
1558 std::string onc_blob; | |
1559 std::string passcode; | |
1560 if (list->GetSize() != 2 || | |
1561 !list->GetString(0, &onc_blob) || | |
1562 !list->GetString(1, &passcode)) { | |
1563 NOTREACHED(); | |
1564 } | |
1565 | |
1566 GetNSSCertDatabaseForProfile( | |
1567 Profile::FromWebUI(web_ui()), | |
1568 base::Bind(&NetInternalsMessageHandler::ImportONCFileToNSSDB, AsWeakPtr(), | |
1569 onc_blob, passcode)); | |
1570 } | |
1571 | |
1549 void NetInternalsMessageHandler::OnStoreDebugLogs(const base::ListValue* list) { | 1572 void NetInternalsMessageHandler::OnStoreDebugLogs(const base::ListValue* list) { |
1550 DCHECK(list); | 1573 DCHECK(list); |
1551 | 1574 |
1552 SendJavascriptCommand("receivedStoreDebugLogs", | 1575 SendJavascriptCommand("receivedStoreDebugLogs", |
1553 new base::StringValue("Creating log file...")); | 1576 new base::StringValue("Creating log file...")); |
1554 const DownloadPrefs* const prefs = | 1577 const DownloadPrefs* const prefs = |
1555 DownloadPrefs::FromBrowserContext(Profile::FromWebUI(web_ui())); | 1578 DownloadPrefs::FromBrowserContext(Profile::FromWebUI(web_ui())); |
1556 StoreDebugLogs(prefs->DownloadPath(), | 1579 StoreDebugLogs(prefs->DownloadPath(), |
1557 base::Bind(&NetInternalsMessageHandler::OnStoreDebugLogsCompleted, | 1580 base::Bind(&NetInternalsMessageHandler::OnStoreDebugLogsCompleted, |
1558 AsWeakPtr())); | 1581 AsWeakPtr())); |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1849 } | 1872 } |
1850 | 1873 |
1851 NetInternalsUI::NetInternalsUI(content::WebUI* web_ui) | 1874 NetInternalsUI::NetInternalsUI(content::WebUI* web_ui) |
1852 : WebUIController(web_ui) { | 1875 : WebUIController(web_ui) { |
1853 web_ui->AddMessageHandler(new NetInternalsMessageHandler()); | 1876 web_ui->AddMessageHandler(new NetInternalsMessageHandler()); |
1854 | 1877 |
1855 // Set up the chrome://net-internals/ source. | 1878 // Set up the chrome://net-internals/ source. |
1856 Profile* profile = Profile::FromWebUI(web_ui); | 1879 Profile* profile = Profile::FromWebUI(web_ui); |
1857 content::WebUIDataSource::Add(profile, CreateNetInternalsHTMLSource()); | 1880 content::WebUIDataSource::Add(profile, CreateNetInternalsHTMLSource()); |
1858 } | 1881 } |
OLD | NEW |