| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_ui.h" | 5 #include "chrome/browser/ui/webui/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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 #include "net/http/http_server_properties.h" | 59 #include "net/http/http_server_properties.h" |
| 60 #include "net/http/http_stream_factory.h" | 60 #include "net/http/http_stream_factory.h" |
| 61 #include "net/proxy/proxy_service.h" | 61 #include "net/proxy/proxy_service.h" |
| 62 #include "net/url_request/url_request_context.h" | 62 #include "net/url_request/url_request_context.h" |
| 63 #include "net/url_request/url_request_context_getter.h" | 63 #include "net/url_request/url_request_context_getter.h" |
| 64 #include "ui/base/l10n/l10n_util.h" | 64 #include "ui/base/l10n/l10n_util.h" |
| 65 #include "ui/base/resource/resource_bundle.h" | 65 #include "ui/base/resource/resource_bundle.h" |
| 66 | 66 |
| 67 #ifdef OS_CHROMEOS | 67 #ifdef OS_CHROMEOS |
| 68 #include "chrome/browser/chromeos/cros/cros_library.h" | 68 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 69 #include "chrome/browser/chromeos/cros/network_library.h" |
| 69 #include "chrome/browser/chromeos/system/syslogs_provider.h" | 70 #include "chrome/browser/chromeos/system/syslogs_provider.h" |
| 70 #endif | 71 #endif |
| 71 #ifdef OS_WIN | 72 #ifdef OS_WIN |
| 72 #include "chrome/browser/net/service_providers_win.h" | 73 #include "chrome/browser/net/service_providers_win.h" |
| 73 #endif | 74 #endif |
| 74 | 75 |
| 75 using content::BrowserThread; | 76 using content::BrowserThread; |
| 76 | 77 |
| 77 namespace { | 78 namespace { |
| 78 | 79 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 const content::NotificationDetails& details) OVERRIDE; | 174 const content::NotificationDetails& details) OVERRIDE; |
| 174 | 175 |
| 175 // Javascript message handlers. | 176 // Javascript message handlers. |
| 176 void OnRendererReady(const ListValue* list); | 177 void OnRendererReady(const ListValue* list); |
| 177 void OnEnableHttpThrottling(const ListValue* list); | 178 void OnEnableHttpThrottling(const ListValue* list); |
| 178 void OnClearBrowserCache(const ListValue* list); | 179 void OnClearBrowserCache(const ListValue* list); |
| 179 void OnGetPrerenderInfo(const ListValue* list); | 180 void OnGetPrerenderInfo(const ListValue* list); |
| 180 #ifdef OS_CHROMEOS | 181 #ifdef OS_CHROMEOS |
| 181 void OnRefreshSystemLogs(const ListValue* list); | 182 void OnRefreshSystemLogs(const ListValue* list); |
| 182 void OnGetSystemLog(const ListValue* list); | 183 void OnGetSystemLog(const ListValue* list); |
| 184 void OnImportONCFile(const ListValue* list); |
| 183 #endif | 185 #endif |
| 184 | 186 |
| 185 private: | 187 private: |
| 186 class IOThreadImpl; | 188 class IOThreadImpl; |
| 187 | 189 |
| 188 #ifdef OS_CHROMEOS | 190 #ifdef OS_CHROMEOS |
| 189 // Class that is used for getting network related ChromeOS logs. | 191 // Class that is used for getting network related ChromeOS logs. |
| 190 // Logs are fetched from ChromeOS libcros on user request, and only when we | 192 // Logs are fetched from ChromeOS libcros on user request, and only when we |
| 191 // don't yet have a copy of logs. If a copy is present, we send back data from | 193 // don't yet have a copy of logs. If a copy is present, we send back data from |
| 192 // it, else we save request and answer to it when we get logs from libcros. | 194 // it, else we save request and answer to it when we get logs from libcros. |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 base::Unretained(this))); | 555 base::Unretained(this))); |
| 554 #ifdef OS_CHROMEOS | 556 #ifdef OS_CHROMEOS |
| 555 web_ui_->RegisterMessageCallback( | 557 web_ui_->RegisterMessageCallback( |
| 556 "refreshSystemLogs", | 558 "refreshSystemLogs", |
| 557 base::Bind(&NetInternalsMessageHandler::OnRefreshSystemLogs, | 559 base::Bind(&NetInternalsMessageHandler::OnRefreshSystemLogs, |
| 558 base::Unretained(this))); | 560 base::Unretained(this))); |
| 559 web_ui_->RegisterMessageCallback( | 561 web_ui_->RegisterMessageCallback( |
| 560 "getSystemLog", | 562 "getSystemLog", |
| 561 base::Bind(&NetInternalsMessageHandler::OnGetSystemLog, | 563 base::Bind(&NetInternalsMessageHandler::OnGetSystemLog, |
| 562 base::Unretained(this))); | 564 base::Unretained(this))); |
| 565 web_ui_->RegisterMessageCallback( |
| 566 "importONCFile", |
| 567 base::Bind(&NetInternalsMessageHandler::OnImportONCFile, |
| 568 base::Unretained(this))); |
| 563 #endif | 569 #endif |
| 564 } | 570 } |
| 565 | 571 |
| 566 void NetInternalsMessageHandler::SendJavascriptCommand( | 572 void NetInternalsMessageHandler::SendJavascriptCommand( |
| 567 const std::string& command, | 573 const std::string& command, |
| 568 Value* arg) { | 574 Value* arg) { |
| 569 scoped_ptr<Value> command_value(Value::CreateStringValue(command)); | 575 scoped_ptr<Value> command_value(Value::CreateStringValue(command)); |
| 570 scoped_ptr<Value> value(arg); | 576 scoped_ptr<Value> value(arg); |
| 571 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 577 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 572 if (value.get()) { | 578 if (value.get()) { |
| (...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1272 void NetInternalsMessageHandler::OnRefreshSystemLogs(const ListValue* list) { | 1278 void NetInternalsMessageHandler::OnRefreshSystemLogs(const ListValue* list) { |
| 1273 DCHECK(syslogs_getter_.get()); | 1279 DCHECK(syslogs_getter_.get()); |
| 1274 syslogs_getter_->DeleteSystemLogs(); | 1280 syslogs_getter_->DeleteSystemLogs(); |
| 1275 syslogs_getter_->LoadSystemLogs(); | 1281 syslogs_getter_->LoadSystemLogs(); |
| 1276 } | 1282 } |
| 1277 | 1283 |
| 1278 void NetInternalsMessageHandler::OnGetSystemLog(const ListValue* list) { | 1284 void NetInternalsMessageHandler::OnGetSystemLog(const ListValue* list) { |
| 1279 DCHECK(syslogs_getter_.get()); | 1285 DCHECK(syslogs_getter_.get()); |
| 1280 syslogs_getter_->RequestSystemLog(list); | 1286 syslogs_getter_->RequestSystemLog(list); |
| 1281 } | 1287 } |
| 1288 |
| 1289 void NetInternalsMessageHandler::OnImportONCFile(const ListValue* list) { |
| 1290 std::string onc_blob; |
| 1291 std::string passcode; |
| 1292 if (list->GetSize() != 2 || |
| 1293 !list->GetString(0, &onc_blob) || |
| 1294 !list->GetString(1, &passcode)) { |
| 1295 NOTREACHED(); |
| 1296 } |
| 1297 |
| 1298 const bool success = chromeos::CrosLibrary::Get()->GetNetworkLibrary()-> |
| 1299 LoadOncNetworks(onc_blob, passcode); |
| 1300 SendJavascriptCommand("receivedONCFileParse", |
| 1301 Value::CreateBooleanValue(success)); |
| 1302 } |
| 1282 #endif | 1303 #endif |
| 1283 | 1304 |
| 1284 void NetInternalsMessageHandler::IOThreadImpl::OnSetLogLevel( | 1305 void NetInternalsMessageHandler::IOThreadImpl::OnSetLogLevel( |
| 1285 const ListValue* list) { | 1306 const ListValue* list) { |
| 1286 int log_level; | 1307 int log_level; |
| 1287 std::string log_level_string; | 1308 std::string log_level_string; |
| 1288 if (!list->GetString(0, &log_level_string) || | 1309 if (!list->GetString(0, &log_level_string) || |
| 1289 !base::StringToInt(log_level_string, &log_level)) { | 1310 !base::StringToInt(log_level_string, &log_level)) { |
| 1290 NOTREACHED(); | 1311 NOTREACHED(); |
| 1291 return; | 1312 return; |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1551 return constants_dict; | 1572 return constants_dict; |
| 1552 } | 1573 } |
| 1553 | 1574 |
| 1554 NetInternalsUI::NetInternalsUI(TabContents* contents) : ChromeWebUI(contents) { | 1575 NetInternalsUI::NetInternalsUI(TabContents* contents) : ChromeWebUI(contents) { |
| 1555 AddMessageHandler((new NetInternalsMessageHandler())->Attach(this)); | 1576 AddMessageHandler((new NetInternalsMessageHandler())->Attach(this)); |
| 1556 | 1577 |
| 1557 // Set up the chrome://net-internals/ source. | 1578 // Set up the chrome://net-internals/ source. |
| 1558 GetProfile()->GetChromeURLDataManager()->AddDataSource( | 1579 GetProfile()->GetChromeURLDataManager()->AddDataSource( |
| 1559 CreateNetInternalsHTMLSource()); | 1580 CreateNetInternalsHTMLSource()); |
| 1560 } | 1581 } |
| OLD | NEW |