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

Side by Side 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: 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/webui/chromeos/diagnostics/diagnostics_ui.h"
6
7 #include "base/bind.h"
8 #include "base/memory/weak_ptr.h"
9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h"
11 #include "chrome/common/url_constants.h"
12 #include "content/public/browser/browser_thread.h"
13 #include "content/public/browser/web_ui.h"
14 #include "content/public/browser/web_ui_message_handler.h"
15 #include "grit/browser_resources.h"
16
17 namespace chromeos {
18
19 namespace {
20
21 ////////////////////////////////////////////////////////////////////////////////
22 // DiagnosticsHandler
23
24 // Class to handle messages from chrome://diagnostics.
25 class DiagnosticsWebUIHandler : public content::WebUIMessageHandler {
26 public:
27 DiagnosticsWebUIHandler()
28 : weak_ptr_factory_(this) {
29 }
30 virtual ~DiagnosticsWebUIHandler() { }
31
32 private:
33 // WebUIMessageHandler override.
James Hawkins 2012/08/01 00:47:42 s/override/implementation/
hshi1 2012/08/01 00:57:10 Done.
34 virtual void RegisterMessages() OVERRIDE;
35
36 // Called when the page is first loaded.
37 void OnPageLoaded(const base::ListValue* args);
38
39 base::WeakPtrFactory<DiagnosticsWebUIHandler> weak_ptr_factory_;
40 DISALLOW_COPY_AND_ASSIGN(DiagnosticsWebUIHandler);
41 };
42
43 void DiagnosticsWebUIHandler::RegisterMessages() {
44 web_ui()->RegisterMessageCallback(
45 "pageLoaded",
46 base::Bind(&DiagnosticsWebUIHandler::OnPageLoaded,
47 weak_ptr_factory_.GetWeakPtr()));
48 }
49
50 void DiagnosticsWebUIHandler::OnPageLoaded(const base::ListValue* args) {
51 // TODO: invoke debugd methods to retrieve diagnostics information, and
James Hawkins 2012/08/01 00:47:42 s/debugd/debug/ ...right?
hshi1 2012/08/01 00:57:10 Actually no the 'debugd' here refers to the debug
52 // upon completion call javascript function to update status.
53 }
54
55 } // namespace
56
57 ////////////////////////////////////////////////////////////////////////////////
58 // DiagnosticsUI
59
60 DiagnosticsUI::DiagnosticsUI(content::WebUI* web_ui)
61 : WebUIController(web_ui) {
62 web_ui->AddMessageHandler(new DiagnosticsWebUIHandler());
63
64 ChromeWebUIDataSource* source =
65 new ChromeWebUIDataSource(chrome::kChromeUIDiagnosticsHost);
66 source->add_resource_path("main.css", IDR_DIAGNOSTICS_MAIN_CSS);
67 source->add_resource_path("main.js", IDR_DIAGNOSTICS_MAIN_JS);
68 source->set_default_resource(IDR_DIAGNOSTICS_MAIN_HTML);
69
70 Profile* profile = Profile::FromWebUI(web_ui);
71 ChromeURLDataManager::AddDataSource(profile, source);
72 }
73
74 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698