Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / webui / help / help_handler.h
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 #ifndef CHROME_BROWSER_UI_WEBUI_HELP_HELP_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_HELP_HELP_HANDLER_H_
7
8 #include <string>
9
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"
16
17 #if defined(OS_CHROMEOS)
18 #include "base/platform_file.h"
19 #include "chrome/browser/chromeos/version_loader.h"
20 #endif  // defined(OS_CHROMEOS)
21
22 namespace content {
23 class WebUIDataSource;
24 }
25
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();
32
33   // WebUIMessageHandler implementation.
34   virtual void RegisterMessages() OVERRIDE;
35
36   // Fills |source| with string values for the UI.
37   void GetLocalizedValues(content::WebUIDataSource* source);
38
39   // NotificationObserver implementation.
40   virtual void Observe(int type, const content::NotificationSource& source,
41                        const content::NotificationDetails& details) OVERRIDE;
42
43  private:
44   // Initializes querying values for the page.
45   void OnPageLoaded(const base::ListValue* args);
46
47 #if defined(OS_MACOSX)
48   // Promotes the updater for all users.
49   void PromoteUpdater(const base::ListValue* args);
50 #endif
51
52   // Relaunches the browser. |args| must be empty.
53   void RelaunchNow(const base::ListValue* args);
54
55   // Opens the feedback dialog. |args| must be empty.
56   void OpenFeedbackDialog(const base::ListValue* args);
57
58   // Opens the help page. |args| must be empty.
59   void OpenHelpPage(const base::ListValue* args);
60
61 #if defined(OS_CHROMEOS)
62   // Sets the release track version.
63   void SetChannel(const base::ListValue* args);
64
65   // Performs relaunch and powerwash.
66   void RelaunchAndPowerwash(const base::ListValue* args);
67 #endif
68
69   // Callback method which forwards status updates to the page.
70   void SetUpdateStatus(VersionUpdater::Status status, int progress,
71                        const base::string16& fail_message);
72
73 #if defined(OS_MACOSX)
74   // Callback method which forwards promotion state to the page.
75   void SetPromotionState(VersionUpdater::PromotionState state);
76 #endif
77
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
85
86   // Specialized instance of the VersionUpdater used to update the browser.
87   scoped_ptr<VersionUpdater> version_updater_;
88
89   // Used to observe notifications.
90   content::NotificationRegistrar registrar_;
91
92 #if defined(OS_CHROMEOS)
93   // Handles asynchronously loading the CrOS version info.
94   chromeos::VersionLoader loader_;
95
96   // Used to request the version.
97   base::CancelableTaskTracker tracker_;
98 #endif  // defined(OS_CHROMEOS)
99
100   // Used for callbacks.
101   base::WeakPtrFactory<HelpHandler> weak_factory_;
102
103   DISALLOW_COPY_AND_ASSIGN(HelpHandler);
104 };
105
106 #endif  // CHROME_BROWSER_UI_WEBUI_HELP_HELP_HANDLER_H_