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 1409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1501 | 1503 |
1502 void NetInternalsMessageHandler::OnImportONCFile(const ListValue* list) { | 1504 void NetInternalsMessageHandler::OnImportONCFile(const ListValue* list) { |
1503 std::string onc_blob; | 1505 std::string onc_blob; |
1504 std::string passcode; | 1506 std::string passcode; |
1505 if (list->GetSize() != 2 || | 1507 if (list->GetSize() != 2 || |
1506 !list->GetString(0, &onc_blob) || | 1508 !list->GetString(0, &onc_blob) || |
1507 !list->GetString(1, &passcode)) { | 1509 !list->GetString(1, &passcode)) { |
1508 NOTREACHED(); | 1510 NOTREACHED(); |
1509 } | 1511 } |
1510 | 1512 |
| 1513 chromeos::onc::ONCSource onc_source = chromeos::onc::ONC_SOURCE_USER_IMPORT; |
| 1514 |
| 1515 base::ListValue network_configs; |
| 1516 base::ListValue certificates; |
1511 std::string error; | 1517 std::string error; |
1512 chromeos::NetworkLibrary* cros_network = | 1518 if (!chromeos::onc::ParseAndValidateOncForImport( |
1513 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); | 1519 onc_blob, onc_source, passcode, &network_configs, &certificates)) { |
1514 if (!cros_network->LoadOncNetworks(onc_blob, passcode, | 1520 error = "Errors occurred during the ONC parsing."; |
1515 chromeos::onc::ONC_SOURCE_USER_IMPORT, | |
1516 NULL)) { | |
1517 error = "Errors occurred during the ONC import."; | |
1518 LOG(ERROR) << error; | 1521 LOG(ERROR) << error; |
1519 } | 1522 } |
1520 | 1523 |
| 1524 chromeos::NetworkLibrary* network_library = |
| 1525 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); |
| 1526 network_library->LoadOncNetworks(network_configs, onc_source); |
1521 // Now that we've added the networks, we need to rescan them so they'll be | 1527 // Now that we've added the networks, we need to rescan them so they'll be |
1522 // available from the menu more immediately. | 1528 // available from the menu more immediately. |
1523 cros_network->RequestNetworkScan(); | 1529 network_library->RequestNetworkScan(); |
| 1530 |
| 1531 chromeos::CertificateHandler certificate_handler; |
| 1532 if (!certificate_handler.ImportCertificates(certificates, onc_source, NULL)) { |
| 1533 error += "Some certificates couldn't be imported."; |
| 1534 LOG(ERROR) << error; |
| 1535 } |
1524 | 1536 |
1525 SendJavascriptCommand("receivedONCFileParse", | 1537 SendJavascriptCommand("receivedONCFileParse", |
1526 Value::CreateStringValue(error)); | 1538 Value::CreateStringValue(error)); |
1527 } | 1539 } |
1528 | 1540 |
1529 void NetInternalsMessageHandler::OnStoreDebugLogs(const ListValue* list) { | 1541 void NetInternalsMessageHandler::OnStoreDebugLogs(const ListValue* list) { |
1530 DCHECK(list); | 1542 DCHECK(list); |
1531 StoreDebugLogs( | 1543 StoreDebugLogs( |
1532 base::Bind(&NetInternalsMessageHandler::OnStoreDebugLogsCompleted, | 1544 base::Bind(&NetInternalsMessageHandler::OnStoreDebugLogsCompleted, |
1533 AsWeakPtr())); | 1545 AsWeakPtr())); |
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1932 } | 1944 } |
1933 | 1945 |
1934 NetInternalsUI::NetInternalsUI(content::WebUI* web_ui) | 1946 NetInternalsUI::NetInternalsUI(content::WebUI* web_ui) |
1935 : WebUIController(web_ui) { | 1947 : WebUIController(web_ui) { |
1936 web_ui->AddMessageHandler(new NetInternalsMessageHandler()); | 1948 web_ui->AddMessageHandler(new NetInternalsMessageHandler()); |
1937 | 1949 |
1938 // Set up the chrome://net-internals/ source. | 1950 // Set up the chrome://net-internals/ source. |
1939 Profile* profile = Profile::FromWebUI(web_ui); | 1951 Profile* profile = Profile::FromWebUI(web_ui); |
1940 content::WebUIDataSource::Add(profile, CreateNetInternalsHTMLSource()); | 1952 content::WebUIDataSource::Add(profile, CreateNetInternalsHTMLSource()); |
1941 } | 1953 } |
OLD | NEW |