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

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

Issue 2925973002: Migrate upgrade notifications to observer (Closed)
Patch Set: Add DISALLOW_COPY_AND_ASSIGN Created 3 years, 6 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 2016 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_SETTINGS_ABOUT_HANDLER_H_ 5 #ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_ABOUT_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_SETTINGS_ABOUT_HANDLER_H_ 6 #define CHROME_BROWSER_UI_WEBUI_SETTINGS_ABOUT_HANDLER_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "base/strings/string16.h" 14 #include "base/strings/string16.h"
15 #include "build/build_config.h" 15 #include "build/build_config.h"
16 #include "chrome/browser/ui/webui/help/version_updater.h" 16 #include "chrome/browser/ui/webui/help/version_updater.h"
17 #include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h" 17 #include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
18 #include "chrome/browser/upgrade_observer.h"
18 #include "components/policy/core/common/policy_service.h" 19 #include "components/policy/core/common/policy_service.h"
19 #include "content/public/browser/notification_observer.h"
20 #include "content/public/browser/notification_registrar.h"
21 #include "content/public/browser/web_ui_message_handler.h" 20 #include "content/public/browser/web_ui_message_handler.h"
22 21
23 #if defined(OS_CHROMEOS) 22 #if defined(OS_CHROMEOS)
24 #include "base/task/cancelable_task_tracker.h" 23 #include "base/task/cancelable_task_tracker.h"
25 #include "chromeos/system/version_loader.h" 24 #include "chromeos/system/version_loader.h"
26 #endif // defined(OS_CHROMEOS) 25 #endif // defined(OS_CHROMEOS)
27 26
28 namespace base { 27 namespace base {
29 class DictionaryValue; 28 class DictionaryValue;
30 class FilePath; 29 class FilePath;
31 class ListValue; 30 class ListValue;
32 } 31 }
33 32
34 namespace content { 33 namespace content {
35 class WebUIDataSource; 34 class WebUIDataSource;
36 } 35 }
37 36
38 class Profile; 37 class Profile;
39 38
40 namespace settings { 39 namespace settings {
41 40
42 // WebUI message handler for the help page. 41 // WebUI message handler for the help page.
43 class AboutHandler : public settings::SettingsPageUIHandler, 42 class AboutHandler : public settings::SettingsPageUIHandler,
44 public content::NotificationObserver { 43 public UpgradeObserver {
45 public: 44 public:
46 AboutHandler(); 45 AboutHandler();
47 ~AboutHandler() override; 46 ~AboutHandler() override;
48 47
49 static AboutHandler* Create(content::WebUIDataSource* html_source, 48 static AboutHandler* Create(content::WebUIDataSource* html_source,
50 Profile* profile); 49 Profile* profile);
51 50
52 // WebUIMessageHandler implementation. 51 // WebUIMessageHandler implementation.
53 void RegisterMessages() override; 52 void RegisterMessages() override;
54 void OnJavascriptAllowed() override; 53 void OnJavascriptAllowed() override;
55 void OnJavascriptDisallowed() override; 54 void OnJavascriptDisallowed() override;
56 55
57 // NotificationObserver implementation. 56 // UpgradeObserver implementation.
58 void Observe(int type, 57 void OnUpgradeRecommended() override;
59 const content::NotificationSource& source,
60 const content::NotificationDetails& details) override;
61 58
62 // Returns the browser version as a string. 59 // Returns the browser version as a string.
63 static base::string16 BuildBrowserVersionString(); 60 static base::string16 BuildBrowserVersionString();
64 61
65 private: 62 private:
66 void OnDeviceAutoUpdatePolicyChanged(const base::Value* previous_policy, 63 void OnDeviceAutoUpdatePolicyChanged(const base::Value* previous_policy,
67 const base::Value* current_policy); 64 const base::Value* current_policy);
68 65
69 // Called once the JS page is ready to be called, serves as a signal to the 66 // Called once the JS page is ready to be called, serves as a signal to the
70 // handler to register C++ observers. 67 // handler to register C++ observers.
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 141
145 // Callback for when the regulatory text has been read. 142 // Callback for when the regulatory text has been read.
146 void OnRegulatoryLabelTextRead(std::string callback_id, 143 void OnRegulatoryLabelTextRead(std::string callback_id,
147 const base::FilePath& label_dir_path, 144 const base::FilePath& label_dir_path,
148 const std::string& text); 145 const std::string& text);
149 #endif 146 #endif
150 147
151 // Specialized instance of the VersionUpdater used to update the browser. 148 // Specialized instance of the VersionUpdater used to update the browser.
152 std::unique_ptr<VersionUpdater> version_updater_; 149 std::unique_ptr<VersionUpdater> version_updater_;
153 150
154 // Used to observe notifications.
155 content::NotificationRegistrar registrar_;
156
157 // Used to observe changes in the |kDeviceAutoUpdateDisabled| policy. 151 // Used to observe changes in the |kDeviceAutoUpdateDisabled| policy.
158 std::unique_ptr<policy::PolicyChangeRegistrar> policy_registrar_; 152 std::unique_ptr<policy::PolicyChangeRegistrar> policy_registrar_;
159 153
154 // If true changes to UpgradeObserver are applied, if false they are ignored.
155 bool apply_changes_from_upgrade_observer_;
156
160 // Used for callbacks. 157 // Used for callbacks.
161 base::WeakPtrFactory<AboutHandler> weak_factory_; 158 base::WeakPtrFactory<AboutHandler> weak_factory_;
162 159
163 DISALLOW_COPY_AND_ASSIGN(AboutHandler); 160 DISALLOW_COPY_AND_ASSIGN(AboutHandler);
164 }; 161 };
165 162
166 } // namespace settings 163 } // namespace settings
167 164
168 #endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_ABOUT_HANDLER_H_ 165 #endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_ABOUT_HANDLER_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/help/help_handler.cc ('k') | chrome/browser/ui/webui/settings/about_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698