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 class ASH_EXPORT NightLightController : public SessionObserver { | |
|
James Cook
2017/05/05 17:12:31
nit: Please add a class comment with a one-line de
afakhry
2017/05/05 20:04:11
Done.
| |
| 19 public: | |
| 20 class Observer { | |
| 21 public: | |
| 22 Observer() {} | |
|
James Cook
2017/05/05 17:12:31
nit: We usually write observers as:
class Observe
afakhry
2017/05/05 20:04:10
Done.
| |
| 23 virtual ~Observer() {} | |
| 24 | |
| 25 // Emitted when the night light status is changed. | |
| 26 virtual void OnStatusChanged(bool new_status) = 0; | |
|
James Cook
2017/05/05 17:12:31
nit: Maybe OnNightLightChanged(bool enabled)? That
afakhry
2017/05/05 20:04:11
Done.
| |
| 27 | |
| 28 private: | |
| 29 DISALLOW_COPY_AND_ASSIGN(Observer); | |
| 30 }; | |
| 31 | |
| 32 explicit NightLightController(SessionController* session_controller); | |
| 33 ~NightLightController() override; | |
| 34 | |
| 35 static void RegisterPrefs(PrefRegistrySimple* registry); | |
| 36 | |
| 37 static void DisableAnimationsForTests(); | |
|
James Cook
2017/05/05 17:12:31
nit: ForTest or ForTesting
Also, document which a
afakhry
2017/05/05 20:04:10
Done.
| |
| 38 | |
| 39 float color_temperature() const { return color_temperature_; } | |
| 40 bool enabled() const { return enabled_; } | |
| 41 | |
| 42 void AddObserver(Observer* observer); | |
| 43 void RemoveObserver(Observer* observer); | |
| 44 | |
| 45 void Toggle(); | |
| 46 | |
| 47 void SetEnabled(bool enabled); | |
|
James Cook
2017/05/05 17:12:31
Do you need both Toggle() and enabled()/SetEnabled
afakhry
2017/05/05 20:04:10
SetEnabled() is useful for initializing from prefs
| |
| 48 | |
| 49 void SetColorTemperature(float temperature); | |
|
James Cook
2017/05/05 17:12:31
nit: document expected values for temperature, or
afakhry
2017/05/05 20:04:11
Done.
| |
| 50 | |
| 51 // ash::SessionObserver: | |
| 52 void OnActiveUserSessionChanged(const AccountId& account_id) override; | |
| 53 void OnSessionStateChanged(session_manager::SessionState state) override; | |
| 54 | |
| 55 private: | |
| 56 void Refresh(); | |
| 57 | |
| 58 void InitFromUserPrefs(); | |
| 59 | |
| 60 void PersistUserPrefs(); | |
| 61 | |
| 62 void NotifyStatusChanged(); | |
| 63 | |
| 64 // The observed session controller instance from which we know when to | |
| 65 // initialize the NightLight settings from the user preferences. | |
| 66 SessionController* const session_controller_; | |
| 67 | |
| 68 // The applied color temperature value when NightLight is turned ON. It's a | |
| 69 // value from 0.0f (least warm -- NightLight is OFF) to 1.0f (most warm). | |
|
James Cook
2017/05/05 17:12:31
Is 0.0 equivalent to nightlight off? If so, do you
afakhry
2017/05/05 20:04:11
Yes 0.0f === off. But I still need enabled_. The i
James Cook
2017/05/05 20:47:43
So it's possible to turn Night Light on, but the c
afakhry
2017/05/06 00:49:34
Oh I think I might need to remove that "OFF" comme
| |
| 70 float color_temperature_ = 0.5f; | |
| 71 | |
| 72 bool enabled_ = false; | |
| 73 | |
| 74 base::ObserverList<Observer> observers_; | |
| 75 | |
| 76 DISALLOW_COPY_AND_ASSIGN(NightLightController); | |
| 77 }; | |
| 78 | |
| 79 } // namespace ash | |
| 80 | |
| 81 #endif // ASH_SYSTEM_NIGHT_LIGHT_NIGHT_LIGHT_CONTROLLER_H_ | |
| OLD | NEW |