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_
10 #include "base/compiler_specific.h"
11 #include "base/memory/weak_ptr.h"
12 #include "base/strings/string16.h"
13 #include "chrome/browser/ui/webui/help/version_updater.h"
14 #include "content/public/browser/notification_observer.h"
15 #include "content/public/browser/notification_registrar.h"
16 #include "content/public/browser/web_ui_message_handler.h"
18 #if defined(OS_CHROMEOS)
19 #include "base/task/cancelable_task_tracker.h"
20 #include "chromeos/system/version_loader.h"
21 #endif // defined(OS_CHROMEOS)
24 class DictionaryValue
;
29 // WebUI message handler for the help page.
30 class HelpHandler
: public content::WebUIMessageHandler
,
31 public content::NotificationObserver
{
34 ~HelpHandler() override
;
36 // WebUIMessageHandler implementation.
37 void RegisterMessages() override
;
39 // Adds string values for the UI to |localized_strings|.
40 static void GetLocalizedValues(base::DictionaryValue
* localized_strings
);
42 // NotificationObserver implementation.
43 void Observe(int type
,
44 const content::NotificationSource
& source
,
45 const content::NotificationDetails
& details
) override
;
47 // Returns the browser version as a string.
48 static base::string16
BuildBrowserVersionString();
51 // Initializes querying values for the page.
52 void OnPageLoaded(const base::ListValue
* args
);
54 #if defined(OS_MACOSX)
55 // Promotes the updater for all users.
56 void PromoteUpdater(const base::ListValue
* args
);
59 // Relaunches the browser. |args| must be empty.
60 void RelaunchNow(const base::ListValue
* args
);
62 // Opens the feedback dialog. |args| must be empty.
63 void OpenFeedbackDialog(const base::ListValue
* args
);
65 // Opens the help page. |args| must be empty.
66 void OpenHelpPage(const base::ListValue
* args
);
68 #if defined(OS_CHROMEOS)
69 // Sets the release track version.
70 void SetChannel(const base::ListValue
* args
);
72 // Performs relaunch and powerwash.
73 void RelaunchAndPowerwash(const base::ListValue
* args
);
76 // Checks for and applies update.
77 void RequestUpdate(const base::ListValue
* args
);
79 // Callback method which forwards status updates to the page.
80 void SetUpdateStatus(VersionUpdater::Status status
,
82 const base::string16
& fail_message
);
84 #if defined(OS_MACOSX)
85 // Callback method which forwards promotion state to the page.
86 void SetPromotionState(VersionUpdater::PromotionState state
);
89 #if defined(OS_CHROMEOS)
90 // Callbacks from VersionLoader.
91 void OnOSVersion(const std::string
& version
);
92 void OnOSFirmware(const std::string
& firmware
);
93 void OnCurrentChannel(const std::string
& channel
);
94 void OnTargetChannel(const std::string
& channel
);
96 // Callback for when the directory with the regulatory label image and alt
97 // text has been found.
98 void OnRegulatoryLabelDirFound(const base::FilePath
& path
);
100 // Callback for setting the regulatory label source.
101 void OnRegulatoryLabelImageFound(const base::FilePath
& path
);
103 // Callback for setting the regulatory label alt text.
104 void OnRegulatoryLabelTextRead(const std::string
& text
);
107 // Specialized instance of the VersionUpdater used to update the browser.
108 scoped_ptr
<VersionUpdater
> version_updater_
;
110 // Used to observe notifications.
111 content::NotificationRegistrar registrar_
;
113 // Used for callbacks.
114 base::WeakPtrFactory
<HelpHandler
> weak_factory_
;
116 DISALLOW_COPY_AND_ASSIGN(HelpHandler
);
119 #endif // CHROME_BROWSER_UI_WEBUI_HELP_HELP_HANDLER_H_