| 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 1558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1569 | 1569 |
| 1570 base::ListValue network_configs; | 1570 base::ListValue network_configs; |
| 1571 base::ListValue certificates; | 1571 base::ListValue certificates; |
| 1572 std::string error; | 1572 std::string error; |
| 1573 if (!chromeos::onc::ParseAndValidateOncForImport( | 1573 if (!chromeos::onc::ParseAndValidateOncForImport( |
| 1574 onc_blob, onc_source, passcode, &network_configs, &certificates)) { | 1574 onc_blob, onc_source, passcode, &network_configs, &certificates)) { |
| 1575 error = "Errors occurred during the ONC parsing."; | 1575 error = "Errors occurred during the ONC parsing."; |
| 1576 LOG(ERROR) << error; | 1576 LOG(ERROR) << error; |
| 1577 } | 1577 } |
| 1578 | 1578 |
| 1579 chromeos::CertificateHandler::CertsByGUID imported_server_and_ca_certs; |
| 1580 chromeos::CertificateHandler certificate_handler; |
| 1581 if (!certificate_handler.ImportCertificates(certificates, onc_source, NULL, |
| 1582 &imported_server_and_ca_certs)) { |
| 1583 error += "Some certificates couldn't be imported."; |
| 1584 LOG(ERROR) << error; |
| 1585 } |
| 1586 |
| 1587 if (!chromeos::onc::ResolveServerCertRefsInNetworks( |
| 1588 imported_server_and_ca_certs, &network_configs)) { |
| 1589 error += "Some certificate references could not be resolved."; |
| 1590 LOG(ERROR) << error; |
| 1591 } |
| 1592 |
| 1593 net::CertificateList imported_server_and_ca_certs_list; |
| 1594 for (chromeos::CertificateHandler::CertsByGUID::iterator it = |
| 1595 imported_server_and_ca_certs.begin(); |
| 1596 it != imported_server_and_ca_certs.end(); ++it) { |
| 1597 imported_server_and_ca_certs_list.push_back(it->second); |
| 1598 } |
| 1579 chromeos::NetworkLibrary* network_library = | 1599 chromeos::NetworkLibrary* network_library = |
| 1580 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); | 1600 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); |
| 1581 network_library->LoadOncNetworks(network_configs, onc_source); | 1601 network_library->LoadOncNetworks( |
| 1602 network_configs, |
| 1603 onc_source, |
| 1604 base::Bind(&chromeos::onc::GetPEMEncodedCertFromFingerprint, |
| 1605 imported_server_and_ca_certs_list)); |
| 1582 // Now that we've added the networks, we need to rescan them so they'll be | 1606 // Now that we've added the networks, we need to rescan them so they'll be |
| 1583 // available from the menu more immediately. | 1607 // available from the menu more immediately. |
| 1584 network_library->RequestNetworkScan(); | 1608 network_library->RequestNetworkScan(); |
| 1585 | 1609 |
| 1586 chromeos::CertificateHandler certificate_handler; | |
| 1587 if (!certificate_handler.ImportCertificates(certificates, onc_source, NULL)) { | |
| 1588 error += "Some certificates couldn't be imported."; | |
| 1589 LOG(ERROR) << error; | |
| 1590 } | |
| 1591 | |
| 1592 SendJavascriptCommand("receivedONCFileParse", | 1610 SendJavascriptCommand("receivedONCFileParse", |
| 1593 Value::CreateStringValue(error)); | 1611 Value::CreateStringValue(error)); |
| 1594 } | 1612 } |
| 1595 | 1613 |
| 1596 void NetInternalsMessageHandler::OnStoreDebugLogs(const ListValue* list) { | 1614 void NetInternalsMessageHandler::OnStoreDebugLogs(const ListValue* list) { |
| 1597 DCHECK(list); | 1615 DCHECK(list); |
| 1598 StoreDebugLogs( | 1616 StoreDebugLogs( |
| 1599 base::Bind(&NetInternalsMessageHandler::OnStoreDebugLogsCompleted, | 1617 base::Bind(&NetInternalsMessageHandler::OnStoreDebugLogsCompleted, |
| 1600 AsWeakPtr())); | 1618 AsWeakPtr())); |
| 1601 } | 1619 } |
| (...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1999 } | 2017 } |
| 2000 | 2018 |
| 2001 NetInternalsUI::NetInternalsUI(content::WebUI* web_ui) | 2019 NetInternalsUI::NetInternalsUI(content::WebUI* web_ui) |
| 2002 : WebUIController(web_ui) { | 2020 : WebUIController(web_ui) { |
| 2003 web_ui->AddMessageHandler(new NetInternalsMessageHandler()); | 2021 web_ui->AddMessageHandler(new NetInternalsMessageHandler()); |
| 2004 | 2022 |
| 2005 // Set up the chrome://net-internals/ source. | 2023 // Set up the chrome://net-internals/ source. |
| 2006 Profile* profile = Profile::FromWebUI(web_ui); | 2024 Profile* profile = Profile::FromWebUI(web_ui); |
| 2007 content::WebUIDataSource::Add(profile, CreateNetInternalsHTMLSource()); | 2025 content::WebUIDataSource::Add(profile, CreateNetInternalsHTMLSource()); |
| 2008 } | 2026 } |
| OLD | NEW |