OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef ASH_SYSTEM_NIGHT_LIGHT_NIGHT_LIGHT_CONTROLLER_H_ |
| 6 #define ASH_SYSTEM_NIGHT_LIGHT_NIGHT_LIGHT_CONTROLLER_H_ |
| 7 |
| 8 #include "ash/ash_export.h" |
| 9 #include "ash/session/session_observer.h" |
| 10 #include "base/observer_list.h" |
| 11 |
| 12 class PrefRegistrySimple; |
| 13 |
| 14 namespace ash { |
| 15 |
| 16 class SessionController; |
| 17 |
| 18 // Controls the NightLight feature that adjusts the color temperature of the |
| 19 // screen. |
| 20 class ASH_EXPORT NightLightController : public SessionObserver { |
| 21 public: |
| 22 class Observer { |
| 23 public: |
| 24 // Emitted when the NightLight status is changed. |
| 25 virtual void OnNightLightEnabledChanged(bool enabled) = 0; |
| 26 |
| 27 protected: |
| 28 virtual ~Observer() {} |
| 29 }; |
| 30 |
| 31 explicit NightLightController(SessionController* session_controller); |
| 32 ~NightLightController() override; |
| 33 |
| 34 static void RegisterPrefs(PrefRegistrySimple* registry); |
| 35 |
| 36 float color_temperature() const { return color_temperature_; } |
| 37 bool enabled() const { return enabled_; } |
| 38 |
| 39 void AddObserver(Observer* observer); |
| 40 void RemoveObserver(Observer* observer); |
| 41 |
| 42 void Toggle(); |
| 43 |
| 44 void SetEnabled(bool enabled); |
| 45 |
| 46 // Set the screen color temperature. |temperature| should be a value from |
| 47 // 0.0f (least warm) to 1.0f (most warm). |
| 48 void SetColorTemperature(float temperature); |
| 49 |
| 50 // ash::SessionObserver: |
| 51 void OnActiveUserSessionChanged(const AccountId& account_id) override; |
| 52 |
| 53 private: |
| 54 void Refresh(); |
| 55 |
| 56 void InitFromUserPrefs(); |
| 57 |
| 58 void PersistUserPrefs(); |
| 59 |
| 60 void NotifyStatusChanged(); |
| 61 |
| 62 // The observed session controller instance from which we know when to |
| 63 // initialize the NightLight settings from the user preferences. |
| 64 SessionController* const session_controller_; |
| 65 |
| 66 // The applied color temperature value when NightLight is turned ON. It's a |
| 67 // value from 0.0f (least warm, default display color) to 1.0f (most warm). |
| 68 float color_temperature_ = 0.5f; |
| 69 |
| 70 bool enabled_ = false; |
| 71 |
| 72 base::ObserverList<Observer> observers_; |
| 73 |
| 74 DISALLOW_COPY_AND_ASSIGN(NightLightController); |
| 75 }; |
| 76 |
| 77 } // namespace ash |
| 78 |
| 79 #endif // ASH_SYSTEM_NIGHT_LIGHT_NIGHT_LIGHT_CONTROLLER_H_ |
OLD | NEW |