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

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

Issue 10827148: diagnostics: Add connectivity section to chrome://diagnostics (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase to revision 150108. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/resources/chromeos/diagnostics/main.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/chromeos/diagnostics/diagnostics_ui.cc
diff --git a/chrome/browser/ui/webui/chromeos/diagnostics/diagnostics_ui.cc b/chrome/browser/ui/webui/chromeos/diagnostics/diagnostics_ui.cc
index 40768cf22b1944a4e2af49cc536c05ebdb689b2a..fc278a0869c683b823dc8e6b94b0bed22083b1e6 100644
--- a/chrome/browser/ui/webui/chromeos/diagnostics/diagnostics_ui.cc
+++ b/chrome/browser/ui/webui/chromeos/diagnostics/diagnostics_ui.cc
@@ -5,10 +5,13 @@
#include "chrome/browser/ui/webui/chromeos/diagnostics/diagnostics_ui.h"
#include "base/bind.h"
+#include "base/json/json_reader.h"
#include "base/memory/weak_ptr.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/chrome_web_ui_data_source.h"
#include "chrome/common/url_constants.h"
+#include "chromeos/dbus/debug_daemon_client.h"
+#include "chromeos/dbus/dbus_thread_manager.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_message_handler.h"
@@ -18,6 +21,9 @@ namespace chromeos {
namespace {
+// JS API callback names.
+const char kJsApiUpdateConnStatus[] = "updateConnectivityStatus";
+
////////////////////////////////////////////////////////////////////////////////
// DiagnosticsHandler
@@ -36,6 +42,12 @@ class DiagnosticsWebUIHandler : public content::WebUIMessageHandler {
// Called when the page is first loaded.
void OnPageLoaded(const base::ListValue* args);
+ // Called when GetNetworkInterfaces() is complete.
+ // |succeeded|: information was obtained successfully.
+ // |status|: network interfaces information in json. See
+ // DebugDaemonClient::GetNetworkInterfaces() for details.
+ void OnGetNetworkInterfaces(bool succeeded, const std::string& status);
+
base::WeakPtrFactory<DiagnosticsWebUIHandler> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(DiagnosticsWebUIHandler);
};
@@ -48,8 +60,25 @@ void DiagnosticsWebUIHandler::RegisterMessages() {
}
void DiagnosticsWebUIHandler::OnPageLoaded(const base::ListValue* args) {
- // TODO: invoke debugd methods to retrieve diagnostics information, and
- // upon completion call javascript function to update status.
+ chromeos::DebugDaemonClient* debugd_client =
+ chromeos::DBusThreadManager::Get()->GetDebugDaemonClient();
+ DCHECK(debugd_client);
+
+ debugd_client->GetNetworkInterfaces(
+ base::Bind(&DiagnosticsWebUIHandler::OnGetNetworkInterfaces,
+ weak_ptr_factory_.GetWeakPtr()));
+}
+
+void DiagnosticsWebUIHandler::OnGetNetworkInterfaces(
+ bool succeeded, const std::string& status) {
+ if (!succeeded)
+ return;
+ scoped_ptr<Value> parsed_value(base::JSONReader::Read(status));
+ if (parsed_value.get() && parsed_value->IsType(Value::TYPE_DICTIONARY)) {
+ base::DictionaryValue* result =
+ static_cast<DictionaryValue*>(parsed_value.get());
+ web_ui()->CallJavascriptFunction(kJsApiUpdateConnStatus, *result);
+ }
}
} // namespace
@@ -63,6 +92,8 @@ DiagnosticsUI::DiagnosticsUI(content::WebUI* web_ui)
ChromeWebUIDataSource* source =
new ChromeWebUIDataSource(chrome::kChromeUIDiagnosticsHost);
+ source->add_resource_path("main.css", IDR_DIAGNOSTICS_MAIN_CSS);
+ source->add_resource_path("main.js", IDR_DIAGNOSTICS_MAIN_JS);
source->set_default_resource(IDR_DIAGNOSTICS_MAIN_HTML);
Profile* profile = Profile::FromWebUI(web_ui);
« no previous file with comments | « chrome/browser/resources/chromeos/diagnostics/main.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698