Chromium Code Reviews| 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 void OnSessionStateChanged(session_manager::SessionState state) override; | |
| 53 | |
| 54 private: | |
| 55 void Refresh(); | |
| 56 | |
| 57 void InitFromUserPrefs(); | |
| 58 | |
| 59 void PersistUserPrefs(); | |
| 60 | |
| 61 void NotifyStatusChanged(); | |
| 62 | |
| 63 // The observed session controller instance from which we know when to | |
| 64 // initialize the NightLight settings from the user preferences. | |
| 65 SessionController* const session_controller_; | |
| 66 | |
| 67 // The applied color temperature value when NightLight is turned ON. It's a | |
| 68 // value from 0.0f (least warm -- NightLight is OFF) to 1.0f (most warm). | |
|
James Cook
2017/05/08 16:09:07
nit: Instead of "NightLight is OFF" (which sounds
afakhry
2017/05/08 17:36:26
Yes, much better! Thanks.
Done.
| |
| 69 float color_temperature_ = 0.5f; | |
| 70 | |
| 71 bool enabled_ = false; | |
| 72 | |
| 73 base::ObserverList<Observer> observers_; | |
| 74 | |
| 75 DISALLOW_COPY_AND_ASSIGN(NightLightController); | |
| 76 }; | |
| 77 | |
| 78 } // namespace ash | |
| 79 | |
| 80 #endif // ASH_SYSTEM_NIGHT_LIGHT_NIGHT_LIGHT_CONTROLLER_H_ | |
| OLD | NEW |