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 1469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1480 | 1480 |
1481 void NetInternalsMessageHandler::OnImportONCFile(const ListValue* list) { | 1481 void NetInternalsMessageHandler::OnImportONCFile(const ListValue* list) { |
1482 std::string onc_blob; | 1482 std::string onc_blob; |
1483 std::string passcode; | 1483 std::string passcode; |
1484 if (list->GetSize() != 2 || | 1484 if (list->GetSize() != 2 || |
1485 !list->GetString(0, &onc_blob) || | 1485 !list->GetString(0, &onc_blob) || |
1486 !list->GetString(1, &passcode)) { | 1486 !list->GetString(1, &passcode)) { |
1487 NOTREACHED(); | 1487 NOTREACHED(); |
1488 } | 1488 } |
1489 | 1489 |
1490 std::string error; | 1490 std::string messages; |
1491 chromeos::NetworkLibrary* cros_network = | 1491 chromeos::NetworkLibrary* cros_network = |
1492 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); | 1492 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); |
1493 cros_network->LoadOncNetworks(onc_blob, passcode, | 1493 bool success = cros_network->LoadOncNetworks( |
1494 chromeos::NetworkUIData::ONC_SOURCE_USER_IMPORT, | 1494 onc_blob, passcode, |
1495 false, // allow_web_trust_from_policy | 1495 chromeos::NetworkUIData::ONC_SOURCE_USER_IMPORT, |
1496 &error); | 1496 false, // allow_web_trust_from_policy |
| 1497 &messages); |
| 1498 |
| 1499 LOG(WARNING) << "LoadOncNetworks result: " << (success ? "true":"false") |
| 1500 << ", " << messages; |
1497 | 1501 |
1498 // Now that we've added the networks, we need to rescan them so they'll be | 1502 // Now that we've added the networks, we need to rescan them so they'll be |
1499 // available from the menu more immediately. | 1503 // available from the menu more immediately. |
1500 cros_network->RequestNetworkScan(); | 1504 cros_network->RequestNetworkScan(); |
1501 | 1505 |
1502 SendJavascriptCommand("receivedONCFileParse", | 1506 base::DictionaryValue *params = new base::DictionaryValue(); |
1503 Value::CreateStringValue(error)); | 1507 params->Set("message", base::Value::CreateStringValue(messages)); |
| 1508 params->Set("success", base::Value::CreateBooleanValue(success)); |
| 1509 SendJavascriptCommand("receivedONCFileParse", params); |
1504 } | 1510 } |
1505 | 1511 |
1506 void NetInternalsMessageHandler::OnStoreDebugLogs(const ListValue* list) { | 1512 void NetInternalsMessageHandler::OnStoreDebugLogs(const ListValue* list) { |
1507 DCHECK(!list); | 1513 DCHECK(!list); |
1508 StoreDebugLogs( | 1514 StoreDebugLogs( |
1509 base::Bind(&NetInternalsMessageHandler::OnStoreDebugLogsCompleted, | 1515 base::Bind(&NetInternalsMessageHandler::OnStoreDebugLogsCompleted, |
1510 AsWeakPtr())); | 1516 AsWeakPtr())); |
1511 } | 1517 } |
1512 | 1518 |
1513 void NetInternalsMessageHandler::OnStoreDebugLogsCompleted( | 1519 void NetInternalsMessageHandler::OnStoreDebugLogsCompleted( |
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1909 } | 1915 } |
1910 | 1916 |
1911 NetInternalsUI::NetInternalsUI(content::WebUI* web_ui) | 1917 NetInternalsUI::NetInternalsUI(content::WebUI* web_ui) |
1912 : WebUIController(web_ui) { | 1918 : WebUIController(web_ui) { |
1913 web_ui->AddMessageHandler(new NetInternalsMessageHandler()); | 1919 web_ui->AddMessageHandler(new NetInternalsMessageHandler()); |
1914 | 1920 |
1915 // Set up the chrome://net-internals/ source. | 1921 // Set up the chrome://net-internals/ source. |
1916 Profile* profile = Profile::FromWebUI(web_ui); | 1922 Profile* profile = Profile::FromWebUI(web_ui); |
1917 ChromeURLDataManager::AddDataSource(profile, CreateNetInternalsHTMLSource()); | 1923 ChromeURLDataManager::AddDataSource(profile, CreateNetInternalsHTMLSource()); |
1918 } | 1924 } |
OLD | NEW |