| OLD | NEW |
| 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_CHROMEOS_DATE_TIME_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_DATE_TIME_HANDLER_H_ |
| 6 #define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_DATE_TIME_HANDLER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_DATE_TIME_HANDLER_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "chrome/browser/chromeos/settings/cros_settings.h" | 10 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 11 #include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h" | 11 #include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h" |
| 12 #include "chromeos/dbus/system_clock_client.h" |
| 12 #include "components/prefs/pref_change_registrar.h" | 13 #include "components/prefs/pref_change_registrar.h" |
| 13 | 14 |
| 14 namespace base { | 15 namespace base { |
| 15 class ListValue; | 16 class ListValue; |
| 16 } | 17 } |
| 17 | 18 |
| 18 namespace content { | 19 namespace content { |
| 19 class WebUIDataSource; | 20 class WebUIDataSource; |
| 20 } | 21 } |
| 21 | 22 |
| 22 namespace chromeos { | 23 namespace chromeos { |
| 23 namespace settings { | 24 namespace settings { |
| 24 | 25 |
| 25 // Chrome OS date and time settings page UI handler. | 26 // Chrome OS date and time settings page UI handler. |
| 26 class DateTimeHandler : public ::settings::SettingsPageUIHandler { | 27 class DateTimeHandler : public ::settings::SettingsPageUIHandler, |
| 28 public SystemClockClient::Observer { |
| 27 public: | 29 public: |
| 28 ~DateTimeHandler() override; | 30 ~DateTimeHandler() override; |
| 29 | 31 |
| 30 // Adds load-time values to html_source before creating the handler. | 32 // Adds load-time values to html_source before creating the handler. |
| 31 static DateTimeHandler* Create(content::WebUIDataSource* html_source); | 33 static DateTimeHandler* Create(content::WebUIDataSource* html_source); |
| 32 | 34 |
| 33 // SettingsPageUIHandler implementation. | 35 // SettingsPageUIHandler implementation. |
| 34 void RegisterMessages() override; | 36 void RegisterMessages() override; |
| 35 void OnJavascriptAllowed() override; | 37 void OnJavascriptAllowed() override; |
| 36 void OnJavascriptDisallowed() override; | 38 void OnJavascriptDisallowed() override; |
| 37 | 39 |
| 38 private: | 40 private: |
| 39 DateTimeHandler(); | 41 DateTimeHandler(); |
| 40 | 42 |
| 43 // SystemClockClient::Observer implementation. |
| 44 void SystemClockCanSetTimeChanged(bool can_set_time) override; |
| 45 |
| 41 // Called when the page is ready. | 46 // Called when the page is ready. |
| 42 void HandleDateTimePageReady(const base::ListValue* args); | 47 void HandleDateTimePageReady(const base::ListValue* args); |
| 43 | 48 |
| 44 // Handler to fetch the list of time zones. | 49 // Handler to fetch the list of time zones. |
| 45 void HandleGetTimeZones(const base::ListValue* args); | 50 void HandleGetTimeZones(const base::ListValue* args); |
| 46 | 51 |
| 52 // Called to show the Set Time UI. |
| 53 void HandleShowSetDateTimeUI(const base::ListValue* args); |
| 54 |
| 47 // Updates the UI, enabling or disabling the time zone automatic detection | 55 // Updates the UI, enabling or disabling the time zone automatic detection |
| 48 // setting according to policy. | 56 // setting according to policy. |
| 49 void NotifyTimezoneAutomaticDetectionPolicy(); | 57 void NotifyTimezoneAutomaticDetectionPolicy(); |
| 50 | 58 |
| 51 std::unique_ptr<chromeos::CrosSettings::ObserverSubscription> | 59 std::unique_ptr<chromeos::CrosSettings::ObserverSubscription> |
| 52 system_timezone_policy_subscription_; | 60 system_timezone_policy_subscription_; |
| 53 | 61 |
| 54 // Used to listen to changes to the system time zone detection policy. | 62 // Used to listen to changes to the system time zone detection policy. |
| 55 PrefChangeRegistrar local_state_pref_change_registrar_; | 63 PrefChangeRegistrar local_state_pref_change_registrar_; |
| 56 | 64 |
| 57 base::WeakPtrFactory<DateTimeHandler> weak_ptr_factory_; | 65 base::WeakPtrFactory<DateTimeHandler> weak_ptr_factory_; |
| 58 | 66 |
| 59 DISALLOW_COPY_AND_ASSIGN(DateTimeHandler); | 67 DISALLOW_COPY_AND_ASSIGN(DateTimeHandler); |
| 60 }; | 68 }; |
| 61 | 69 |
| 62 } // namespace settings | 70 } // namespace settings |
| 63 } // namespace chromeos | 71 } // namespace chromeos |
| 64 | 72 |
| 65 #endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_DATE_TIME_HANDLER_H_ | 73 #endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_DATE_TIME_HANDLER_H_ |
| OLD | NEW |