Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Side by Side Diff: chrome/browser/ui/webui/net_internals/net_internals_ui.cc

Issue 10024056: Added functionality to chrome://net-internals/#chromeos page that user (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 #include "net/proxy/proxy_service.h" 65 #include "net/proxy/proxy_service.h"
66 #include "net/url_request/url_request_context.h" 66 #include "net/url_request/url_request_context.h"
67 #include "net/url_request/url_request_context_getter.h" 67 #include "net/url_request/url_request_context_getter.h"
68 #include "ui/base/l10n/l10n_util.h" 68 #include "ui/base/l10n/l10n_util.h"
69 #include "ui/base/resource/resource_bundle.h" 69 #include "ui/base/resource/resource_bundle.h"
70 70
71 #ifdef OS_CHROMEOS 71 #ifdef OS_CHROMEOS
72 #include "chrome/browser/chromeos/cros/cros_library.h" 72 #include "chrome/browser/chromeos/cros/cros_library.h"
73 #include "chrome/browser/chromeos/cros/network_library.h" 73 #include "chrome/browser/chromeos/cros/network_library.h"
74 #include "chrome/browser/chromeos/system/syslogs_provider.h" 74 #include "chrome/browser/chromeos/system/syslogs_provider.h"
75 #include "chromeos/dbus/dbus_thread_manager.h"
76 #include "chromeos/dbus/debug_daemon_client.h"
75 #endif 77 #endif
76 #ifdef OS_WIN 78 #ifdef OS_WIN
77 #include "chrome/browser/net/service_providers_win.h" 79 #include "chrome/browser/net/service_providers_win.h"
78 #endif 80 #endif
79 81
80 using content::BrowserThread; 82 using content::BrowserThread;
81 using content::WebContents; 83 using content::WebContents;
82 using content::WebUIMessageHandler; 84 using content::WebUIMessageHandler;
83 85
84 namespace { 86 namespace {
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 182
181 // Javascript message handlers. 183 // Javascript message handlers.
182 void OnRendererReady(const ListValue* list); 184 void OnRendererReady(const ListValue* list);
183 void OnEnableHttpThrottling(const ListValue* list); 185 void OnEnableHttpThrottling(const ListValue* list);
184 void OnClearBrowserCache(const ListValue* list); 186 void OnClearBrowserCache(const ListValue* list);
185 void OnGetPrerenderInfo(const ListValue* list); 187 void OnGetPrerenderInfo(const ListValue* list);
186 #ifdef OS_CHROMEOS 188 #ifdef OS_CHROMEOS
187 void OnRefreshSystemLogs(const ListValue* list); 189 void OnRefreshSystemLogs(const ListValue* list);
188 void OnGetSystemLog(const ListValue* list); 190 void OnGetSystemLog(const ListValue* list);
189 void OnImportONCFile(const ListValue* list); 191 void OnImportONCFile(const ListValue* list);
192 void OnSetNetworkDebugMode(const ListValue* list);
193 void OnSetNetworkDebugModeCompleted(const std::string& subsystem,
194 bool succeeded);
190 #endif 195 #endif
191 196
192 private: 197 private:
193 class IOThreadImpl; 198 class IOThreadImpl;
194 199
195 #ifdef OS_CHROMEOS 200 #ifdef OS_CHROMEOS
196 // Class that is used for getting network related ChromeOS logs. 201 // Class that is used for getting network related ChromeOS logs.
197 // Logs are fetched from ChromeOS libcros on user request, and only when we 202 // Logs are fetched from ChromeOS libcros on user request, and only when we
198 // don't yet have a copy of logs. If a copy is present, we send back data from 203 // don't yet have a copy of logs. If a copy is present, we send back data from
199 // it, else we save request and answer to it when we get logs from libcros. 204 // it, else we save request and answer to it when we get logs from libcros.
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 base::Bind(&NetInternalsMessageHandler::OnRefreshSystemLogs, 554 base::Bind(&NetInternalsMessageHandler::OnRefreshSystemLogs,
550 base::Unretained(this))); 555 base::Unretained(this)));
551 web_ui()->RegisterMessageCallback( 556 web_ui()->RegisterMessageCallback(
552 "getSystemLog", 557 "getSystemLog",
553 base::Bind(&NetInternalsMessageHandler::OnGetSystemLog, 558 base::Bind(&NetInternalsMessageHandler::OnGetSystemLog,
554 base::Unretained(this))); 559 base::Unretained(this)));
555 web_ui()->RegisterMessageCallback( 560 web_ui()->RegisterMessageCallback(
556 "importONCFile", 561 "importONCFile",
557 base::Bind(&NetInternalsMessageHandler::OnImportONCFile, 562 base::Bind(&NetInternalsMessageHandler::OnImportONCFile,
558 base::Unretained(this))); 563 base::Unretained(this)));
564 web_ui()->RegisterMessageCallback(
565 "setNetworkDebugMode",
566 base::Bind(&NetInternalsMessageHandler::OnSetNetworkDebugMode,
567 base::Unretained(this)));
559 #endif 568 #endif
560 } 569 }
561 570
562 void NetInternalsMessageHandler::SendJavascriptCommand( 571 void NetInternalsMessageHandler::SendJavascriptCommand(
563 const std::string& command, 572 const std::string& command,
564 Value* arg) { 573 Value* arg) {
565 scoped_ptr<Value> command_value(Value::CreateStringValue(command)); 574 scoped_ptr<Value> command_value(Value::CreateStringValue(command));
566 scoped_ptr<Value> value(arg); 575 scoped_ptr<Value> value(arg);
567 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 576 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
568 if (value.get()) { 577 if (value.get()) {
(...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after
1261 chromeos::NetworkUIData::ONC_SOURCE_USER_IMPORT, 1270 chromeos::NetworkUIData::ONC_SOURCE_USER_IMPORT,
1262 &error); 1271 &error);
1263 1272
1264 // Now that we've added the networks, we need to rescan them so they'll be 1273 // Now that we've added the networks, we need to rescan them so they'll be
1265 // available from the menu more immediately. 1274 // available from the menu more immediately.
1266 cros_network->RequestNetworkScan(); 1275 cros_network->RequestNetworkScan();
1267 1276
1268 SendJavascriptCommand("receivedONCFileParse", 1277 SendJavascriptCommand("receivedONCFileParse",
1269 Value::CreateStringValue(error)); 1278 Value::CreateStringValue(error));
1270 } 1279 }
1280
1281 void NetInternalsMessageHandler::OnSetNetworkDebugMode(const ListValue* list) {
1282 std::string subsystem;
1283 if (list->GetSize() != 1 || !list->GetString(0, &subsystem))
1284 NOTREACHED();
1285 chromeos::DBusThreadManager::Get()->GetDebugDaemonClient()->
1286 SetDebugMode(
1287 subsystem,
1288 base::Bind(
1289 &NetInternalsMessageHandler::OnSetNetworkDebugModeCompleted,
1290 AsWeakPtr(),
1291 subsystem));
1292 }
1293
1294 void NetInternalsMessageHandler::OnSetNetworkDebugModeCompleted(
1295 const std::string& subsystem,
1296 bool succeeded) {
1297 std::string status;
1298 if (succeeded)
1299 status = "Debug mode is changed to " + subsystem;
1300 else
1301 status = "Failed to change debug mode to " + subsystem;
1302 SendJavascriptCommand("receivedSetNetworkDebugMode",
1303 Value::CreateStringValue(status));
1304 }
1305
1271 #endif 1306 #endif
1272 1307
1273 void NetInternalsMessageHandler::IOThreadImpl::OnGetHttpPipeliningStatus( 1308 void NetInternalsMessageHandler::IOThreadImpl::OnGetHttpPipeliningStatus(
1274 const ListValue* list) { 1309 const ListValue* list) {
1275 DictionaryValue* status_dict = new DictionaryValue(); 1310 DictionaryValue* status_dict = new DictionaryValue();
1276 1311
1277 status_dict->Set("pipelining_enabled", 1312 status_dict->Set("pipelining_enabled",
1278 Value::CreateBooleanValue( 1313 Value::CreateBooleanValue(
1279 net::HttpStreamFactory::http_pipelining_enabled())); 1314 net::HttpStreamFactory::http_pipelining_enabled()));
1280 1315
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
1581 1616
1582 NetInternalsUI::NetInternalsUI(content::WebUI* web_ui) 1617 NetInternalsUI::NetInternalsUI(content::WebUI* web_ui)
1583 : WebUIController(web_ui) { 1618 : WebUIController(web_ui) {
1584 web_ui->AddMessageHandler(new NetInternalsMessageHandler()); 1619 web_ui->AddMessageHandler(new NetInternalsMessageHandler());
1585 1620
1586 // Set up the chrome://net-internals/ source. 1621 // Set up the chrome://net-internals/ source.
1587 Profile* profile = Profile::FromWebUI(web_ui); 1622 Profile* profile = Profile::FromWebUI(web_ui);
1588 profile->GetChromeURLDataManager()->AddDataSource( 1623 profile->GetChromeURLDataManager()->AddDataSource(
1589 CreateNetInternalsHTMLSource()); 1624 CreateNetInternalsHTMLSource());
1590 } 1625 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698