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

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

Issue 8741009: ONC import option to chromeos tab in chrome://net-internals (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: review feedback Created 9 years 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 | Annotate | Revision Log
OLDNEW
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
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
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
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
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 return;
James Hawkins 2011/12/02 22:08:57 Don't handle NOTREACHEDs by returning. http://www
achuithb 2011/12/03 00:23:32 Done.
1297 }
1298
1299 const bool success = chromeos::CrosLibrary::Get()->GetNetworkLibrary()->
1300 LoadOncNetworks(onc_blob, passcode);
1301 SendJavascriptCommand("receivedONCFileParse",
1302 Value::CreateStringValue(success ? "ONC file successfully parsed" :
1303 "ONC file parse failed"));
1304 }
1282 #endif 1305 #endif
1283 1306
1284 void NetInternalsMessageHandler::IOThreadImpl::OnSetLogLevel( 1307 void NetInternalsMessageHandler::IOThreadImpl::OnSetLogLevel(
1285 const ListValue* list) { 1308 const ListValue* list) {
1286 int log_level; 1309 int log_level;
1287 std::string log_level_string; 1310 std::string log_level_string;
1288 if (!list->GetString(0, &log_level_string) || 1311 if (!list->GetString(0, &log_level_string) ||
1289 !base::StringToInt(log_level_string, &log_level)) { 1312 !base::StringToInt(log_level_string, &log_level)) {
1290 NOTREACHED(); 1313 NOTREACHED();
1291 return; 1314 return;
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
1551 return constants_dict; 1574 return constants_dict;
1552 } 1575 }
1553 1576
1554 NetInternalsUI::NetInternalsUI(TabContents* contents) : ChromeWebUI(contents) { 1577 NetInternalsUI::NetInternalsUI(TabContents* contents) : ChromeWebUI(contents) {
1555 AddMessageHandler((new NetInternalsMessageHandler())->Attach(this)); 1578 AddMessageHandler((new NetInternalsMessageHandler())->Attach(this));
1556 1579
1557 // Set up the chrome://net-internals/ source. 1580 // Set up the chrome://net-internals/ source.
1558 GetProfile()->GetChromeURLDataManager()->AddDataSource( 1581 GetProfile()->GetChromeURLDataManager()->AddDataSource(
1559 CreateNetInternalsHTMLSource()); 1582 CreateNetInternalsHTMLSource());
1560 } 1583 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698