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

Side by Side Diff: chrome/browser/ui/webui/chromeos/diagnostics/diagnostics_ui.cc

Issue 10825291: Diagnostics UI: more UI implementation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Determine active adapter. Created 8 years, 4 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 | Annotate | Revision Log
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/chromeos/diagnostics/diagnostics_ui.h" 5 #include "chrome/browser/ui/webui/chromeos/diagnostics/diagnostics_ui.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/json/json_reader.h" 8 #include "base/json/json_reader.h"
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" 11 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h"
12 #include "chrome/common/url_constants.h" 12 #include "chrome/common/url_constants.h"
13 #include "chromeos/dbus/debug_daemon_client.h" 13 #include "chromeos/dbus/debug_daemon_client.h"
14 #include "chromeos/dbus/dbus_thread_manager.h" 14 #include "chromeos/dbus/dbus_thread_manager.h"
15 #include "content/public/browser/browser_thread.h" 15 #include "content/public/browser/browser_thread.h"
16 #include "content/public/browser/web_ui.h" 16 #include "content/public/browser/web_ui.h"
17 #include "content/public/browser/web_ui_message_handler.h" 17 #include "content/public/browser/web_ui_message_handler.h"
18 #include "grit/browser_resources.h" 18 #include "grit/browser_resources.h"
19 19
20 namespace chromeos { 20 namespace chromeos {
21 21
22 namespace { 22 namespace {
23 23
24 // JS API callback names. 24 // JS API callback names.
25 const char kJsApiUpdateConnStatus[] = "updateConnectivityStatus"; 25 const char kJsApiSetNetifStatus[] = "diag.DiagPage.setNetifStatus";
26 26
27 //////////////////////////////////////////////////////////////////////////////// 27 ////////////////////////////////////////////////////////////////////////////////
28 // DiagnosticsHandler 28 // DiagnosticsHandler
29 29
30 // Class to handle messages from chrome://diagnostics. 30 // Class to handle messages from chrome://diagnostics.
31 class DiagnosticsWebUIHandler : public content::WebUIMessageHandler { 31 class DiagnosticsWebUIHandler : public content::WebUIMessageHandler {
32 public: 32 public:
33 DiagnosticsWebUIHandler() 33 DiagnosticsWebUIHandler()
34 : weak_ptr_factory_(this) { 34 : weak_ptr_factory_(this) {
35 } 35 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 } 70 }
71 71
72 void DiagnosticsWebUIHandler::OnGetNetworkInterfaces( 72 void DiagnosticsWebUIHandler::OnGetNetworkInterfaces(
73 bool succeeded, const std::string& status) { 73 bool succeeded, const std::string& status) {
74 if (!succeeded) 74 if (!succeeded)
75 return; 75 return;
76 scoped_ptr<Value> parsed_value(base::JSONReader::Read(status)); 76 scoped_ptr<Value> parsed_value(base::JSONReader::Read(status));
77 if (parsed_value.get() && parsed_value->IsType(Value::TYPE_DICTIONARY)) { 77 if (parsed_value.get() && parsed_value->IsType(Value::TYPE_DICTIONARY)) {
78 base::DictionaryValue* result = 78 base::DictionaryValue* result =
79 static_cast<DictionaryValue*>(parsed_value.get()); 79 static_cast<DictionaryValue*>(parsed_value.get());
80 web_ui()->CallJavascriptFunction(kJsApiUpdateConnStatus, *result); 80 web_ui()->CallJavascriptFunction(kJsApiSetNetifStatus, *result);
81 } 81 }
82 } 82 }
83 83
84 } // namespace 84 } // namespace
85 85
86 //////////////////////////////////////////////////////////////////////////////// 86 ////////////////////////////////////////////////////////////////////////////////
87 // DiagnosticsUI 87 // DiagnosticsUI
88 88
89 DiagnosticsUI::DiagnosticsUI(content::WebUI* web_ui) 89 DiagnosticsUI::DiagnosticsUI(content::WebUI* web_ui)
90 : WebUIController(web_ui) { 90 : WebUIController(web_ui) {
91 web_ui->AddMessageHandler(new DiagnosticsWebUIHandler()); 91 web_ui->AddMessageHandler(new DiagnosticsWebUIHandler());
92 92
93 ChromeWebUIDataSource* source = 93 ChromeWebUIDataSource* source =
94 new ChromeWebUIDataSource(chrome::kChromeUIDiagnosticsHost); 94 new ChromeWebUIDataSource(chrome::kChromeUIDiagnosticsHost);
95 source->add_resource_path("main.css", IDR_DIAGNOSTICS_MAIN_CSS); 95 source->add_resource_path("main.css", IDR_DIAGNOSTICS_MAIN_CSS);
96 source->add_resource_path("main.js", IDR_DIAGNOSTICS_MAIN_JS); 96 source->add_resource_path("main.js", IDR_DIAGNOSTICS_MAIN_JS);
97 source->add_resource_path("fail.png", IDR_DIAGNOSTICS_IMAGES_FAIL);
98 source->add_resource_path("tick.png", IDR_DIAGNOSTICS_IMAGES_TICK);
99 source->add_resource_path("warning.png", IDR_DIAGNOSTICS_IMAGES_WARNING);
97 source->set_default_resource(IDR_DIAGNOSTICS_MAIN_HTML); 100 source->set_default_resource(IDR_DIAGNOSTICS_MAIN_HTML);
98 101
99 Profile* profile = Profile::FromWebUI(web_ui); 102 Profile* profile = Profile::FromWebUI(web_ui);
100 ChromeURLDataManager::AddDataSource(profile, source); 103 ChromeURLDataManager::AddDataSource(profile, source);
101 } 104 }
102 105
103 } // namespace chromeos 106 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698