| 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 1550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1561 NOTREACHED(); | 1561 NOTREACHED(); |
| 1562 } | 1562 } |
| 1563 | 1563 |
| 1564 chromeos::onc::ONCSource onc_source = chromeos::onc::ONC_SOURCE_USER_IMPORT; | 1564 chromeos::onc::ONCSource onc_source = chromeos::onc::ONC_SOURCE_USER_IMPORT; |
| 1565 | 1565 |
| 1566 base::ListValue network_configs; | 1566 base::ListValue network_configs; |
| 1567 base::ListValue certificates; | 1567 base::ListValue certificates; |
| 1568 std::string error; | 1568 std::string error; |
| 1569 if (!chromeos::onc::ParseAndValidateOncForImport( | 1569 if (!chromeos::onc::ParseAndValidateOncForImport( |
| 1570 onc_blob, onc_source, passcode, &network_configs, &certificates)) { | 1570 onc_blob, onc_source, passcode, &network_configs, &certificates)) { |
| 1571 error = "Errors occurred during the ONC parsing."; | 1571 error = "Errors occurred during the ONC parsing. "; |
| 1572 LOG(ERROR) << error; |
| 1573 } |
| 1574 |
| 1575 chromeos::CertificateHandler::CertsByGUID imported_server_and_ca_certs; |
| 1576 chromeos::CertificateHandler certificate_handler; |
| 1577 if (!certificate_handler.ImportCertificates(certificates, onc_source, NULL, |
| 1578 &imported_server_and_ca_certs)) { |
| 1579 error += "Some certificates couldn't be imported. "; |
| 1580 LOG(ERROR) << error; |
| 1581 } |
| 1582 |
| 1583 if (!chromeos::onc::ResolveServerCertRefsInNetworks( |
| 1584 imported_server_and_ca_certs, &network_configs)) { |
| 1585 error += "Some certificate references could not be resolved. "; |
| 1572 LOG(ERROR) << error; | 1586 LOG(ERROR) << error; |
| 1573 } | 1587 } |
| 1574 | 1588 |
| 1575 chromeos::NetworkLibrary* network_library = | 1589 chromeos::NetworkLibrary* network_library = |
| 1576 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); | 1590 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); |
| 1577 network_library->LoadOncNetworks(network_configs, onc_source); | 1591 network_library->LoadOncNetworks(network_configs, onc_source); |
| 1592 |
| 1578 // Now that we've added the networks, we need to rescan them so they'll be | 1593 // Now that we've added the networks, we need to rescan them so they'll be |
| 1579 // available from the menu more immediately. | 1594 // available from the menu more immediately. |
| 1580 network_library->RequestNetworkScan(); | 1595 network_library->RequestNetworkScan(); |
| 1581 | 1596 |
| 1582 chromeos::CertificateHandler certificate_handler; | |
| 1583 if (!certificate_handler.ImportCertificates(certificates, onc_source, NULL)) { | |
| 1584 error += "Some certificates couldn't be imported."; | |
| 1585 LOG(ERROR) << error; | |
| 1586 } | |
| 1587 | |
| 1588 SendJavascriptCommand("receivedONCFileParse", | 1597 SendJavascriptCommand("receivedONCFileParse", |
| 1589 Value::CreateStringValue(error)); | 1598 Value::CreateStringValue(error)); |
| 1590 } | 1599 } |
| 1591 | 1600 |
| 1592 void NetInternalsMessageHandler::OnStoreDebugLogs(const ListValue* list) { | 1601 void NetInternalsMessageHandler::OnStoreDebugLogs(const ListValue* list) { |
| 1593 DCHECK(list); | 1602 DCHECK(list); |
| 1594 StoreDebugLogs( | 1603 StoreDebugLogs( |
| 1595 base::Bind(&NetInternalsMessageHandler::OnStoreDebugLogsCompleted, | 1604 base::Bind(&NetInternalsMessageHandler::OnStoreDebugLogsCompleted, |
| 1596 AsWeakPtr())); | 1605 AsWeakPtr())); |
| 1597 } | 1606 } |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1884 } | 1893 } |
| 1885 | 1894 |
| 1886 NetInternalsUI::NetInternalsUI(content::WebUI* web_ui) | 1895 NetInternalsUI::NetInternalsUI(content::WebUI* web_ui) |
| 1887 : WebUIController(web_ui) { | 1896 : WebUIController(web_ui) { |
| 1888 web_ui->AddMessageHandler(new NetInternalsMessageHandler()); | 1897 web_ui->AddMessageHandler(new NetInternalsMessageHandler()); |
| 1889 | 1898 |
| 1890 // Set up the chrome://net-internals/ source. | 1899 // Set up the chrome://net-internals/ source. |
| 1891 Profile* profile = Profile::FromWebUI(web_ui); | 1900 Profile* profile = Profile::FromWebUI(web_ui); |
| 1892 content::WebUIDataSource::Add(profile, CreateNetInternalsHTMLSource()); | 1901 content::WebUIDataSource::Add(profile, CreateNetInternalsHTMLSource()); |
| 1893 } | 1902 } |
| OLD | NEW |