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

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

Issue 10836039: Chrome diagnostics: First cut at implementing chrome://diagnostics. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address nits from jhawkins@. Created 8 years, 5 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
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
new file mode 100644
index 0000000000000000000000000000000000000000..40768cf22b1944a4e2af49cc536c05ebdb689b2a
--- /dev/null
+++ b/chrome/browser/ui/webui/chromeos/diagnostics/diagnostics_ui.cc
@@ -0,0 +1,72 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/chromeos/diagnostics/diagnostics_ui.h"
+
+#include "base/bind.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 "content/public/browser/browser_thread.h"
+#include "content/public/browser/web_ui.h"
+#include "content/public/browser/web_ui_message_handler.h"
+#include "grit/browser_resources.h"
+
+namespace chromeos {
+
+namespace {
+
+////////////////////////////////////////////////////////////////////////////////
+// DiagnosticsHandler
+
+// Class to handle messages from chrome://diagnostics.
+class DiagnosticsWebUIHandler : public content::WebUIMessageHandler {
+ public:
+ DiagnosticsWebUIHandler()
+ : weak_ptr_factory_(this) {
+ }
+ virtual ~DiagnosticsWebUIHandler() {}
+
+ private:
+ // WebUIMessageHandler implementation.
+ virtual void RegisterMessages() OVERRIDE;
+
+ // Called when the page is first loaded.
+ void OnPageLoaded(const base::ListValue* args);
+
+ base::WeakPtrFactory<DiagnosticsWebUIHandler> weak_ptr_factory_;
+ DISALLOW_COPY_AND_ASSIGN(DiagnosticsWebUIHandler);
+};
+
+void DiagnosticsWebUIHandler::RegisterMessages() {
+ web_ui()->RegisterMessageCallback(
+ "pageLoaded",
+ base::Bind(&DiagnosticsWebUIHandler::OnPageLoaded,
+ weak_ptr_factory_.GetWeakPtr()));
+}
+
+void DiagnosticsWebUIHandler::OnPageLoaded(const base::ListValue* args) {
+ // TODO: invoke debugd methods to retrieve diagnostics information, and
+ // upon completion call javascript function to update status.
+}
+
+} // namespace
+
+////////////////////////////////////////////////////////////////////////////////
+// DiagnosticsUI
+
+DiagnosticsUI::DiagnosticsUI(content::WebUI* web_ui)
+ : WebUIController(web_ui) {
+ web_ui->AddMessageHandler(new DiagnosticsWebUIHandler());
+
+ ChromeWebUIDataSource* source =
+ new ChromeWebUIDataSource(chrome::kChromeUIDiagnosticsHost);
+ source->set_default_resource(IDR_DIAGNOSTICS_MAIN_HTML);
+
+ Profile* profile = Profile::FromWebUI(web_ui);
+ ChromeURLDataManager::AddDataSource(profile, source);
+}
+
+} // namespace chromeos
« no previous file with comments | « chrome/browser/ui/webui/chromeos/diagnostics/diagnostics_ui.h ('k') | chrome/browser/ui/webui/chromeos/sim_unlock_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698