| 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 #include "net/url_request/url_request_context.h" | 71 #include "net/url_request/url_request_context.h" |
| 72 #include "net/url_request/url_request_context_getter.h" | 72 #include "net/url_request/url_request_context_getter.h" |
| 73 #include "ui/base/resource/resource_bundle.h" | 73 #include "ui/base/resource/resource_bundle.h" |
| 74 | 74 |
| 75 #if defined(OS_CHROMEOS) | 75 #if defined(OS_CHROMEOS) |
| 76 #include "chrome/browser/chromeos/cros/cros_library.h" | 76 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 77 #include "chrome/browser/chromeos/cros/network_library.h" | 77 #include "chrome/browser/chromeos/cros/network_library.h" |
| 78 #include "chrome/browser/chromeos/system/syslogs_provider.h" | 78 #include "chrome/browser/chromeos/system/syslogs_provider.h" |
| 79 #include "chromeos/dbus/dbus_thread_manager.h" | 79 #include "chromeos/dbus/dbus_thread_manager.h" |
| 80 #include "chromeos/dbus/debug_daemon_client.h" | 80 #include "chromeos/dbus/debug_daemon_client.h" |
| 81 #include "chromeos/network/certificate_handler.h" |
| 81 #include "chromeos/network/onc/onc_constants.h" | 82 #include "chromeos/network/onc/onc_constants.h" |
| 83 #include "chromeos/network/onc/onc_utils.h" |
| 82 #endif | 84 #endif |
| 83 #if defined(OS_WIN) | 85 #if defined(OS_WIN) |
| 84 #include "chrome/browser/net/service_providers_win.h" | 86 #include "chrome/browser/net/service_providers_win.h" |
| 85 #endif | 87 #endif |
| 86 | 88 |
| 87 using base::PassPlatformFile; | 89 using base::PassPlatformFile; |
| 88 using base::PlatformFile; | 90 using base::PlatformFile; |
| 89 using base::PlatformFileError; | 91 using base::PlatformFileError; |
| 90 using content::BrowserThread; | 92 using content::BrowserThread; |
| 91 using content::WebContents; | 93 using content::WebContents; |
| (...skipping 1415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1507 | 1509 |
| 1508 void NetInternalsMessageHandler::OnImportONCFile(const ListValue* list) { | 1510 void NetInternalsMessageHandler::OnImportONCFile(const ListValue* list) { |
| 1509 std::string onc_blob; | 1511 std::string onc_blob; |
| 1510 std::string passcode; | 1512 std::string passcode; |
| 1511 if (list->GetSize() != 2 || | 1513 if (list->GetSize() != 2 || |
| 1512 !list->GetString(0, &onc_blob) || | 1514 !list->GetString(0, &onc_blob) || |
| 1513 !list->GetString(1, &passcode)) { | 1515 !list->GetString(1, &passcode)) { |
| 1514 NOTREACHED(); | 1516 NOTREACHED(); |
| 1515 } | 1517 } |
| 1516 | 1518 |
| 1519 chromeos::onc::ONCSource onc_source = chromeos::onc::ONC_SOURCE_USER_IMPORT; |
| 1520 |
| 1521 scoped_ptr<base::ListValue> network_configs; |
| 1522 scoped_ptr<base::ListValue> certificates; |
| 1517 std::string error; | 1523 std::string error; |
| 1518 chromeos::NetworkLibrary* cros_network = | 1524 if (!chromeos::onc::ParseAndValidateOncForImport( |
| 1519 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); | 1525 onc_blob, onc_source, passcode, &network_configs, &certificates)) { |
| 1520 if (!cros_network->LoadOncNetworks(onc_blob, passcode, | 1526 error = "Errors occurred during the ONC parsing."; |
| 1521 chromeos::onc::ONC_SOURCE_USER_IMPORT, | |
| 1522 NULL)) { | |
| 1523 error = "Errors occurred during the ONC import."; | |
| 1524 LOG(ERROR) << error; | 1527 LOG(ERROR) << error; |
| 1525 } | 1528 } |
| 1526 | 1529 |
| 1527 // Now that we've added the networks, we need to rescan them so they'll be | 1530 if (network_configs) { |
| 1528 // available from the menu more immediately. | 1531 chromeos::NetworkLibrary* network_library = |
| 1529 cros_network->RequestNetworkScan(); | 1532 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); |
| 1533 network_library->LoadOncNetworks(*network_configs, onc_source); |
| 1534 // Now that we've added the networks, we need to rescan them so they'll be |
| 1535 // available from the menu more immediately. |
| 1536 network_library->RequestNetworkScan(); |
| 1537 } |
| 1538 |
| 1539 if (certificates) { |
| 1540 scoped_ptr<net::CertificateList> web_trust_certs(new net::CertificateList); |
| 1541 if (!chromeos::CertificateHandler::Get()->ImportCertificates( |
| 1542 *certificates, onc_source, web_trust_certs.get())) { |
| 1543 error = "Some certificates couldn't be imported."; |
| 1544 LOG(ERROR) << error; |
| 1545 } |
| 1546 } |
| 1530 | 1547 |
| 1531 SendJavascriptCommand("receivedONCFileParse", | 1548 SendJavascriptCommand("receivedONCFileParse", |
| 1532 Value::CreateStringValue(error)); | 1549 Value::CreateStringValue(error)); |
| 1533 } | 1550 } |
| 1534 | 1551 |
| 1535 void NetInternalsMessageHandler::OnStoreDebugLogs(const ListValue* list) { | 1552 void NetInternalsMessageHandler::OnStoreDebugLogs(const ListValue* list) { |
| 1536 DCHECK(list); | 1553 DCHECK(list); |
| 1537 StoreDebugLogs( | 1554 StoreDebugLogs( |
| 1538 base::Bind(&NetInternalsMessageHandler::OnStoreDebugLogsCompleted, | 1555 base::Bind(&NetInternalsMessageHandler::OnStoreDebugLogsCompleted, |
| 1539 AsWeakPtr())); | 1556 AsWeakPtr())); |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1938 } | 1955 } |
| 1939 | 1956 |
| 1940 NetInternalsUI::NetInternalsUI(content::WebUI* web_ui) | 1957 NetInternalsUI::NetInternalsUI(content::WebUI* web_ui) |
| 1941 : WebUIController(web_ui) { | 1958 : WebUIController(web_ui) { |
| 1942 web_ui->AddMessageHandler(new NetInternalsMessageHandler()); | 1959 web_ui->AddMessageHandler(new NetInternalsMessageHandler()); |
| 1943 | 1960 |
| 1944 // Set up the chrome://net-internals/ source. | 1961 // Set up the chrome://net-internals/ source. |
| 1945 Profile* profile = Profile::FromWebUI(web_ui); | 1962 Profile* profile = Profile::FromWebUI(web_ui); |
| 1946 content::WebUIDataSource::Add(profile, CreateNetInternalsHTMLSource()); | 1963 content::WebUIDataSource::Add(profile, CreateNetInternalsHTMLSource()); |
| 1947 } | 1964 } |
| OLD | NEW |