Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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_HELP_HELP_HANDLER_H_ |
| 6 #define CHROME_BROWSER_UI_WEBUI_HELP_HELP_HANDLER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_HELP_HELP_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/upgrade_observer.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_registrar.h" | |
| 19 #include "content/public/browser/web_ui_message_handler.h" | 18 #include "content/public/browser/web_ui_message_handler.h" |
| 20 | 19 |
| 21 #if defined(OS_CHROMEOS) | 20 #if defined(OS_CHROMEOS) |
| 22 #include "base/task/cancelable_task_tracker.h" | 21 #include "base/task/cancelable_task_tracker.h" |
| 23 #include "chromeos/system/version_loader.h" | 22 #include "chromeos/system/version_loader.h" |
| 24 #include "third_party/cros_system_api/dbus/update_engine/dbus-constants.h" | 23 #include "third_party/cros_system_api/dbus/update_engine/dbus-constants.h" |
| 25 #endif // defined(OS_CHROMEOS) | 24 #endif // defined(OS_CHROMEOS) |
| 26 | 25 |
| 27 namespace base { | 26 namespace base { |
| 28 class DictionaryValue; | 27 class DictionaryValue; |
| 29 class FilePath; | 28 class FilePath; |
| 30 class ListValue; | 29 class ListValue; |
| 31 } | 30 } |
| 32 | 31 |
| 33 // WebUI message handler for the help page. | 32 // WebUI message handler for the help page. |
| 34 class HelpHandler : public content::WebUIMessageHandler, | 33 class HelpHandler : public content::WebUIMessageHandler, |
| 35 public content::NotificationObserver { | 34 public UpgradeObserver { |
| 36 public: | 35 public: |
| 37 HelpHandler(); | 36 HelpHandler(); |
| 38 ~HelpHandler() override; | 37 ~HelpHandler() override; |
| 39 | 38 |
| 40 // WebUIMessageHandler implementation. | 39 // WebUIMessageHandler implementation. |
| 41 void RegisterMessages() override; | 40 void RegisterMessages() override; |
| 42 | 41 |
| 43 // Adds string values for the UI to |localized_strings|. | 42 // Adds string values for the UI to |localized_strings|. |
| 44 static void GetLocalizedValues(base::DictionaryValue* localized_strings); | 43 static void GetLocalizedValues(base::DictionaryValue* localized_strings); |
| 45 | 44 |
| 46 // NotificationObserver implementation. | 45 // UpgradeObserver implementation. |
| 47 void Observe(int type, | 46 void OnUpgradeRecommended() override; |
| 48 const content::NotificationSource& source, | |
| 49 const content::NotificationDetails& details) override; | |
| 50 | 47 |
| 51 // Returns the browser version as a string. | 48 // Returns the browser version as a string. |
| 52 static base::string16 BuildBrowserVersionString(); | 49 static base::string16 BuildBrowserVersionString(); |
| 53 | 50 |
| 54 private: | 51 private: |
| 55 void OnDeviceAutoUpdatePolicyChanged(const base::Value* previous_policy, | 52 void OnDeviceAutoUpdatePolicyChanged(const base::Value* previous_policy, |
| 56 const base::Value* current_policy); | 53 const base::Value* current_policy); |
| 57 | 54 |
| 58 // On ChromeOS, this gets the current update status. On other platforms, it | 55 // On ChromeOS, this gets the current update status. On other platforms, it |
| 59 // will request and perform an update (if one is available). | 56 // will request and perform an update (if one is available). |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 117 // Callback for setting the regulatory label alt text. | 114 // Callback for setting the regulatory label alt text. |
| 118 void OnRegulatoryLabelTextRead(const std::string& text); | 115 void OnRegulatoryLabelTextRead(const std::string& text); |
| 119 | 116 |
| 120 // Callback for setting the eol string text. | 117 // Callback for setting the eol string text. |
| 121 void OnEolStatus(update_engine::EndOfLifeStatus status); | 118 void OnEolStatus(update_engine::EndOfLifeStatus status); |
| 122 #endif | 119 #endif |
| 123 | 120 |
| 124 // Specialized instance of the VersionUpdater used to update the browser. | 121 // Specialized instance of the VersionUpdater used to update the browser. |
| 125 std::unique_ptr<VersionUpdater> version_updater_; | 122 std::unique_ptr<VersionUpdater> version_updater_; |
| 126 | 123 |
| 127 // Used to observe notifications. | |
| 128 content::NotificationRegistrar registrar_; | |
| 129 | |
| 130 // Used to observe changes in the |kDeviceAutoUpdateDisabled| policy. | 124 // Used to observe changes in the |kDeviceAutoUpdateDisabled| policy. |
| 131 policy::PolicyChangeRegistrar policy_registrar_; | 125 policy::PolicyChangeRegistrar policy_registrar_; |
| 132 | 126 |
| 127 // Whether to start listening to upgrade detector. | |
|
sky
2017/06/08 18:09:52
How about: If true changes to UpgradeObserver are
weidongg
2017/06/08 18:58:07
Yes, that's better, thanks. Done.
| |
| 128 bool enable_upgrade_observer_; | |
| 129 | |
| 133 // Used for callbacks. | 130 // Used for callbacks. |
| 134 base::WeakPtrFactory<HelpHandler> weak_factory_; | 131 base::WeakPtrFactory<HelpHandler> weak_factory_; |
| 135 | 132 |
| 136 DISALLOW_COPY_AND_ASSIGN(HelpHandler); | 133 DISALLOW_COPY_AND_ASSIGN(HelpHandler); |
| 137 }; | 134 }; |
| 138 | 135 |
| 139 #endif // CHROME_BROWSER_UI_WEBUI_HELP_HELP_HANDLER_H_ | 136 #endif // CHROME_BROWSER_UI_WEBUI_HELP_HELP_HANDLER_H_ |
| OLD | NEW |