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

Side by Side Diff: chrome/browser/ui/webui/settings/about_handler.h

Issue 1971483002: MD Settings: About page, porting C++ handler and adding browser proxy. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing comments. Created 4 years, 7 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_UI_WEBUI_HELP_HELP_HANDLER_H_ 5 #ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_ABOUT_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_HELP_HELP_HANDLER_H_ 6 #define CHROME_BROWSER_UI_WEBUI_SETTINGS_ABOUT_HANDLER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "base/strings/string16.h" 13 #include "base/strings/string16.h"
14 #include "build/build_config.h" 14 #include "build/build_config.h"
15 #include "chrome/browser/ui/webui/help/version_updater.h" 15 #include "chrome/browser/ui/webui/help/version_updater.h"
16 #include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
16 #include "components/policy/core/common/policy_service.h" 17 #include "components/policy/core/common/policy_service.h"
17 #include "content/public/browser/notification_observer.h" 18 #include "content/public/browser/notification_observer.h"
18 #include "content/public/browser/notification_registrar.h" 19 #include "content/public/browser/notification_registrar.h"
19 #include "content/public/browser/web_ui_message_handler.h" 20 #include "content/public/browser/web_ui_message_handler.h"
20 21
21 #if defined(OS_CHROMEOS) 22 #if defined(OS_CHROMEOS)
22 #include "base/task/cancelable_task_tracker.h" 23 #include "base/task/cancelable_task_tracker.h"
23 #include "chromeos/system/version_loader.h" 24 #include "chromeos/system/version_loader.h"
24 #endif // defined(OS_CHROMEOS) 25 #endif // defined(OS_CHROMEOS)
25 26
26 namespace base { 27 namespace base {
27 class DictionaryValue; 28 class DictionaryValue;
28 class FilePath; 29 class FilePath;
29 class ListValue; 30 class ListValue;
30 } 31 }
31 32
33 namespace content {
34 class WebUIDataSource;
35 }
36
37 class Profile;
38
39 namespace settings {
40
32 // WebUI message handler for the help page. 41 // WebUI message handler for the help page.
33 class HelpHandler : public content::WebUIMessageHandler, 42 class AboutHandler : public settings::SettingsPageUIHandler,
34 public content::NotificationObserver { 43 public content::NotificationObserver {
35 public: 44 public:
36 HelpHandler(); 45 AboutHandler();
37 ~HelpHandler() override; 46 ~AboutHandler() override;
47
48 static AboutHandler* Create(content::WebUIDataSource* html_source,
49 Profile* profile);
38 50
39 // WebUIMessageHandler implementation. 51 // WebUIMessageHandler implementation.
40 void RegisterMessages() override; 52 void RegisterMessages() override;
41 53 void OnJavascriptAllowed() override;
42 // Adds string values for the UI to |localized_strings|. 54 void OnJavascriptDisallowed() override;
43 static void GetLocalizedValues(base::DictionaryValue* localized_strings);
44 55
45 // NotificationObserver implementation. 56 // NotificationObserver implementation.
46 void Observe(int type, 57 void Observe(int type,
47 const content::NotificationSource& source, 58 const content::NotificationSource& source,
48 const content::NotificationDetails& details) override; 59 const content::NotificationDetails& details) override;
49 60
50 // Returns the browser version as a string. 61 // Returns the browser version as a string.
51 static base::string16 BuildBrowserVersionString(); 62 static base::string16 BuildBrowserVersionString();
52 63
53 private: 64 private:
54 void OnDeviceAutoUpdatePolicyChanged(const base::Value* previous_policy, 65 void OnDeviceAutoUpdatePolicyChanged(const base::Value* previous_policy,
55 const base::Value* current_policy); 66 const base::Value* current_policy);
56 67
57 // On ChromeOS, this gets the current update status. On other platforms, it 68 // Called once when the page has loaded. On ChromeOS, this gets the current
58 // will request and perform an update (if one is available). 69 // update status. On other platforms, it will request and perform an update
70 // (if one is available).
71 void HandleRefreshUpdateStatus(const base::ListValue* args);
59 void RefreshUpdateStatus(); 72 void RefreshUpdateStatus();
60 73
61 // Initializes querying values for the page.
62 void OnPageLoaded(const base::ListValue* args);
63
64 #if defined(OS_MACOSX) 74 #if defined(OS_MACOSX)
65 // Promotes the updater for all users. 75 // Promotes the updater for all users.
66 void PromoteUpdater(const base::ListValue* args); 76 void PromoteUpdater(const base::ListValue* args);
67 #endif 77 #endif
68 78
69 // Relaunches the browser. |args| must be empty. 79 // Relaunches the browser. |args| must be empty.
70 void RelaunchNow(const base::ListValue* args); 80 void HandleRelaunchNow(const base::ListValue* args);
71 81
72 // Opens the feedback dialog. |args| must be empty. 82 // Opens the feedback dialog. |args| must be empty.
73 void OpenFeedbackDialog(const base::ListValue* args); 83 void HandleOpenFeedbackDialog(const base::ListValue* args);
74 84
75 // Opens the help page. |args| must be empty. 85 // Opens the help page. |args| must be empty.
76 void OpenHelpPage(const base::ListValue* args); 86 void HandleOpenHelpPage(const base::ListValue* args);
77 87
78 #if defined(OS_CHROMEOS) 88 #if defined(OS_CHROMEOS)
79 // Sets the release track version. 89 // Sets the release track version.
80 void SetChannel(const base::ListValue* args); 90 void HandleSetChannel(const base::ListValue* args);
81 91
82 // Performs relaunch and powerwash. 92 // Checks for and applies update, triggered by JS.
83 void RelaunchAndPowerwash(const base::ListValue* args); 93 void HandleRequestUpdate(const base::ListValue* args);
94
95 // Retrieves OS, ARC and firmware versions.
96 void HandleGetVersionInfo(const base::ListValue* args);
97 void OnGetVersionInfoReady(
98 std::string callback_id,
99 std::unique_ptr<base::DictionaryValue> version_info);
100
101 void HandleGetCurrentChannel(const base::ListValue* args);
102 void HandleGetTargetChannel(const base::ListValue* args);
103 // C++ callback for either of |HandleGetCurrentChannel| or
104 // |HandleGetTargetChannel|,
105 void OnGetChannelReady(std::string callback_id, const std::string& channel);
84 #endif 106 #endif
85 107
86 // Checks for and applies update. 108 // Checks for and applies update.
87 void RequestUpdate(const base::ListValue* args); 109 void RequestUpdate();
88 110
89 // Callback method which forwards status updates to the page. 111 // Callback method which forwards status updates to the page.
90 void SetUpdateStatus(VersionUpdater::Status status, 112 void SetUpdateStatus(VersionUpdater::Status status,
91 int progress, 113 int progress,
92 const base::string16& fail_message); 114 const base::string16& fail_message);
93 115
94 #if defined(OS_MACOSX) 116 #if defined(OS_MACOSX)
95 // Callback method which forwards promotion state to the page. 117 // Callback method which forwards promotion state to the page.
96 void SetPromotionState(VersionUpdater::PromotionState state); 118 void SetPromotionState(VersionUpdater::PromotionState state);
97 #endif 119 #endif
98 120
99 #if defined(OS_CHROMEOS) 121 #if defined(OS_CHROMEOS)
100 // Callbacks from VersionLoader. 122 void HandleGetRegulatoryInfo(const base::ListValue* args);
101 void OnOSVersion(const std::string& version);
102 void OnARCVersion(const std::string& firmware);
103 void OnOSFirmware(const std::string& firmware);
104 void OnCurrentChannel(const std::string& channel);
105 void OnTargetChannel(const std::string& channel);
106 123
107 // Callback for when the directory with the regulatory label image and alt 124 // Callback for when the directory with the regulatory label image and alt
108 // text has been found. 125 // text has been found.
109 void OnRegulatoryLabelDirFound(const base::FilePath& path); 126 void OnRegulatoryLabelDirFound(std::string callback_id,
127 const base::FilePath& path);
110 128
111 // Callback for setting the regulatory label source. 129 // Callback for when the regulatory text has been read.
112 void OnRegulatoryLabelImageFound(const base::FilePath& path); 130 void OnRegulatoryLabelTextRead(std::string callback_id,
113 131 const base::FilePath& path,
114 // Callback for setting the regulatory label alt text. 132 const std::string& text);
115 void OnRegulatoryLabelTextRead(const std::string& text);
116 #endif 133 #endif
117 134
118 // Specialized instance of the VersionUpdater used to update the browser. 135 // Specialized instance of the VersionUpdater used to update the browser.
119 std::unique_ptr<VersionUpdater> version_updater_; 136 std::unique_ptr<VersionUpdater> version_updater_;
120 137
121 // Used to observe notifications. 138 // Used to observe notifications.
122 content::NotificationRegistrar registrar_; 139 content::NotificationRegistrar registrar_;
123 140
124 // Used to observe changes in the |kDeviceAutoUpdateDisabled| policy. 141 // Used to observe changes in the |kDeviceAutoUpdateDisabled| policy.
125 policy::PolicyChangeRegistrar policy_registrar_; 142 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.
126 143
127 // Used for callbacks. 144 // Used for callbacks.
128 base::WeakPtrFactory<HelpHandler> weak_factory_; 145 base::WeakPtrFactory<AboutHandler> weak_factory_;
129 146
130 DISALLOW_COPY_AND_ASSIGN(HelpHandler); 147 DISALLOW_COPY_AND_ASSIGN(AboutHandler);
131 }; 148 };
132 149
133 #endif // CHROME_BROWSER_UI_WEBUI_HELP_HELP_HANDLER_H_ 150 } // namespace settings
151
152 #endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_ABOUT_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698