Componentize SigninManager.
[chromium-blink-merge.git] / chrome / browser / ui / webui / help / help_handler.h
blob67562b9df8c54f87fb699c4d363d9fd1277595e5
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.
5 #ifndef CHROME_BROWSER_UI_WEBUI_HELP_HELP_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_HELP_HELP_HANDLER_H_
8 #include <string>
10 #include "base/compiler_specific.h"
11 #include "base/memory/weak_ptr.h"
12 #include "chrome/browser/ui/webui/help/version_updater.h"
13 #include "content/public/browser/notification_observer.h"
14 #include "content/public/browser/notification_registrar.h"
15 #include "content/public/browser/web_ui_message_handler.h"
17 #if defined(OS_CHROMEOS)
18 #include "base/platform_file.h"
19 #include "chrome/browser/chromeos/version_loader.h"
20 #endif // defined(OS_CHROMEOS)
22 namespace content {
23 class WebUIDataSource;
26 // WebUI message handler for the help page.
27 class HelpHandler : public content::WebUIMessageHandler,
28 public content::NotificationObserver {
29 public:
30 HelpHandler();
31 virtual ~HelpHandler();
33 // WebUIMessageHandler implementation.
34 virtual void RegisterMessages() OVERRIDE;
36 // Fills |source| with string values for the UI.
37 void GetLocalizedValues(content::WebUIDataSource* source);
39 // NotificationObserver implementation.
40 virtual void Observe(int type, const content::NotificationSource& source,
41 const content::NotificationDetails& details) OVERRIDE;
43 private:
44 // Initializes querying values for the page.
45 void OnPageLoaded(const base::ListValue* args);
47 #if defined(OS_MACOSX)
48 // Promotes the updater for all users.
49 void PromoteUpdater(const base::ListValue* args);
50 #endif
52 // Relaunches the browser. |args| must be empty.
53 void RelaunchNow(const base::ListValue* args);
55 // Opens the feedback dialog. |args| must be empty.
56 void OpenFeedbackDialog(const base::ListValue* args);
58 // Opens the help page. |args| must be empty.
59 void OpenHelpPage(const base::ListValue* args);
61 #if defined(OS_CHROMEOS)
62 // Sets the release track version.
63 void SetChannel(const base::ListValue* args);
65 // Performs relaunch and powerwash.
66 void RelaunchAndPowerwash(const base::ListValue* args);
67 #endif
69 // Callback method which forwards status updates to the page.
70 void SetUpdateStatus(VersionUpdater::Status status, int progress,
71 const base::string16& fail_message);
73 #if defined(OS_MACOSX)
74 // Callback method which forwards promotion state to the page.
75 void SetPromotionState(VersionUpdater::PromotionState state);
76 #endif
78 #if defined(OS_CHROMEOS)
79 // Callbacks from VersionLoader.
80 void OnOSVersion(const std::string& version);
81 void OnOSFirmware(const std::string& firmware);
82 void OnCurrentChannel(const std::string& channel);
83 void OnTargetChannel(const std::string& channel);
84 #endif
86 // Specialized instance of the VersionUpdater used to update the browser.
87 scoped_ptr<VersionUpdater> version_updater_;
89 // Used to observe notifications.
90 content::NotificationRegistrar registrar_;
92 #if defined(OS_CHROMEOS)
93 // Handles asynchronously loading the CrOS version info.
94 chromeos::VersionLoader loader_;
96 // Used to request the version.
97 base::CancelableTaskTracker tracker_;
98 #endif // defined(OS_CHROMEOS)
100 // Used for callbacks.
101 base::WeakPtrFactory<HelpHandler> weak_factory_;
103 DISALLOW_COPY_AND_ASSIGN(HelpHandler);
106 #endif // CHROME_BROWSER_UI_WEBUI_HELP_HELP_HANDLER_H_