Chromium Code Reviews| Index: chrome/browser/ui/webui/settings/about_handler.h |
| diff --git a/chrome/browser/ui/webui/help/help_handler.h b/chrome/browser/ui/webui/settings/about_handler.h |
| similarity index 52% |
| copy from chrome/browser/ui/webui/help/help_handler.h |
| copy to chrome/browser/ui/webui/settings/about_handler.h |
| index 95e41f614c2d82d03868f82d33ecedf427633e3f..dc901d62aded7b642bd17d8045731c541d12d99a 100644 |
| --- a/chrome/browser/ui/webui/help/help_handler.h |
| +++ b/chrome/browser/ui/webui/settings/about_handler.h |
| @@ -1,9 +1,9 @@ |
| -// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Copyright 2016 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. |
| -#ifndef CHROME_BROWSER_UI_WEBUI_HELP_HELP_HANDLER_H_ |
| -#define CHROME_BROWSER_UI_WEBUI_HELP_HELP_HANDLER_H_ |
| +#ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_ABOUT_HANDLER_H_ |
| +#define CHROME_BROWSER_UI_WEBUI_SETTINGS_ABOUT_HANDLER_H_ |
| #include <string> |
| @@ -13,6 +13,7 @@ |
| #include "base/strings/string16.h" |
| #include "build/build_config.h" |
| #include "chrome/browser/ui/webui/help/version_updater.h" |
| +#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h" |
| #include "components/policy/core/common/policy_service.h" |
| #include "content/public/browser/notification_observer.h" |
| #include "content/public/browser/notification_registrar.h" |
| @@ -29,18 +30,28 @@ class FilePath; |
| class ListValue; |
| } |
| +namespace content { |
| +class WebUIDataSource; |
| +} |
| + |
| +class Profile; |
| + |
| +namespace settings { |
| + |
| // WebUI message handler for the help page. |
| -class HelpHandler : public content::WebUIMessageHandler, |
| - public content::NotificationObserver { |
| +class AboutHandler : public settings::SettingsPageUIHandler, |
| + public content::NotificationObserver { |
| public: |
| - HelpHandler(); |
| - ~HelpHandler() override; |
| + AboutHandler(); |
| + ~AboutHandler() override; |
| + |
| + static AboutHandler* Create(content::WebUIDataSource* html_source, |
| + Profile* profile); |
| // WebUIMessageHandler implementation. |
| void RegisterMessages() override; |
| - |
| - // Adds string values for the UI to |localized_strings|. |
| - static void GetLocalizedValues(base::DictionaryValue* localized_strings); |
| + void OnJavascriptAllowed() override; |
| + void OnJavascriptDisallowed() override; |
| // NotificationObserver implementation. |
| void Observe(int type, |
| @@ -54,37 +65,48 @@ class HelpHandler : public content::WebUIMessageHandler, |
| void OnDeviceAutoUpdatePolicyChanged(const base::Value* previous_policy, |
| const base::Value* current_policy); |
| - // On ChromeOS, this gets the current update status. On other platforms, it |
| - // will request and perform an update (if one is available). |
| + // Called once when the page has loaded. On ChromeOS, this gets the current |
| + // update status. On other platforms, it will request and perform an update |
| + // (if one is available). |
| + void HandleRefreshUpdateStatus(const base::ListValue* args); |
| void RefreshUpdateStatus(); |
| - // Initializes querying values for the page. |
| - void OnPageLoaded(const base::ListValue* args); |
| - |
| #if defined(OS_MACOSX) |
| // Promotes the updater for all users. |
| void PromoteUpdater(const base::ListValue* args); |
| #endif |
| // Relaunches the browser. |args| must be empty. |
| - void RelaunchNow(const base::ListValue* args); |
| + void HandleRelaunchNow(const base::ListValue* args); |
| // Opens the feedback dialog. |args| must be empty. |
| - void OpenFeedbackDialog(const base::ListValue* args); |
| + void HandleOpenFeedbackDialog(const base::ListValue* args); |
| // Opens the help page. |args| must be empty. |
| - void OpenHelpPage(const base::ListValue* args); |
| + void HandleOpenHelpPage(const base::ListValue* args); |
| #if defined(OS_CHROMEOS) |
| // Sets the release track version. |
| - void SetChannel(const base::ListValue* args); |
| - |
| - // Performs relaunch and powerwash. |
| - void RelaunchAndPowerwash(const base::ListValue* args); |
| + void HandleSetChannel(const base::ListValue* args); |
| + |
| + // Checks for and applies update, triggered by JS. |
| + void HandleRequestUpdate(const base::ListValue* args); |
| + |
| + // Retrieves OS, ARC and firmware versions. |
| + void HandleGetVersionInfo(const base::ListValue* args); |
| + void OnGetVersionInfoReady( |
| + std::string callback_id, |
| + std::unique_ptr<base::DictionaryValue> version_info); |
| + |
| + void HandleGetCurrentChannel(const base::ListValue* args); |
| + void HandleGetTargetChannel(const base::ListValue* args); |
| + // C++ callback for either of |HandleGetCurrentChannel| or |
| + // |HandleGetTargetChannel|, |
| + void OnGetChannelReady(std::string callback_id, const std::string& channel); |
| #endif |
| // Checks for and applies update. |
| - void RequestUpdate(const base::ListValue* args); |
| + void RequestUpdate(); |
| // Callback method which forwards status updates to the page. |
| void SetUpdateStatus(VersionUpdater::Status status, |
| @@ -97,22 +119,17 @@ class HelpHandler : public content::WebUIMessageHandler, |
| #endif |
| #if defined(OS_CHROMEOS) |
| - // Callbacks from VersionLoader. |
| - void OnOSVersion(const std::string& version); |
| - void OnARCVersion(const std::string& firmware); |
| - void OnOSFirmware(const std::string& firmware); |
| - void OnCurrentChannel(const std::string& channel); |
| - void OnTargetChannel(const std::string& channel); |
| + void HandleGetRegulatoryInfo(const base::ListValue* args); |
| // Callback for when the directory with the regulatory label image and alt |
| // text has been found. |
| - void OnRegulatoryLabelDirFound(const base::FilePath& path); |
| + void OnRegulatoryLabelDirFound(std::string callback_id, |
| + const base::FilePath& path); |
| - // Callback for setting the regulatory label source. |
| - void OnRegulatoryLabelImageFound(const base::FilePath& path); |
| - |
| - // Callback for setting the regulatory label alt text. |
| - void OnRegulatoryLabelTextRead(const std::string& text); |
| + // Callback for when the regulatory text has been read. |
| + void OnRegulatoryLabelTextRead(std::string callback_id, |
| + const base::FilePath& path, |
| + const std::string& text); |
| #endif |
| // Specialized instance of the VersionUpdater used to update the browser. |
| @@ -125,9 +142,11 @@ class HelpHandler : public content::WebUIMessageHandler, |
| policy::PolicyChangeRegistrar policy_registrar_; |
|
Dan Beam
2016/05/11 00:10:09
actually, you should just make this:
std::uniqu
dpapad
2016/05/11 00:45:31
Done. Thanks for the suggestion.
|
| // Used for callbacks. |
| - base::WeakPtrFactory<HelpHandler> weak_factory_; |
| + base::WeakPtrFactory<AboutHandler> weak_factory_; |
| - DISALLOW_COPY_AND_ASSIGN(HelpHandler); |
| + DISALLOW_COPY_AND_ASSIGN(AboutHandler); |
| }; |
| -#endif // CHROME_BROWSER_UI_WEBUI_HELP_HELP_HANDLER_H_ |
| +} // namespace settings |
| + |
| +#endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_ABOUT_HANDLER_H_ |