Index: ash/system/night_light/night_light_controller.h |
diff --git a/ash/system/night_light/night_light_controller.h b/ash/system/night_light/night_light_controller.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..f486eb6da52dc618dfbfc563f254c390b23c7421 |
--- /dev/null |
+++ b/ash/system/night_light/night_light_controller.h |
@@ -0,0 +1,81 @@ |
+// Copyright 2017 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef ASH_SYSTEM_NIGHT_LIGHT_NIGHT_LIGHT_CONTROLLER_H_ |
+#define ASH_SYSTEM_NIGHT_LIGHT_NIGHT_LIGHT_CONTROLLER_H_ |
+ |
+#include "ash/ash_export.h" |
+#include "ash/session/session_observer.h" |
+#include "base/observer_list.h" |
+ |
+class PrefRegistrySimple; |
+ |
+namespace ash { |
+ |
+class SessionController; |
+ |
+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.
|
+ public: |
+ class Observer { |
+ public: |
+ 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.
|
+ virtual ~Observer() {} |
+ |
+ // Emitted when the night light status is changed. |
+ 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.
|
+ |
+ private: |
+ DISALLOW_COPY_AND_ASSIGN(Observer); |
+ }; |
+ |
+ explicit NightLightController(SessionController* session_controller); |
+ ~NightLightController() override; |
+ |
+ static void RegisterPrefs(PrefRegistrySimple* registry); |
+ |
+ 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.
|
+ |
+ float color_temperature() const { return color_temperature_; } |
+ bool enabled() const { return enabled_; } |
+ |
+ void AddObserver(Observer* observer); |
+ void RemoveObserver(Observer* observer); |
+ |
+ void Toggle(); |
+ |
+ 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
|
+ |
+ 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.
|
+ |
+ // ash::SessionObserver: |
+ void OnActiveUserSessionChanged(const AccountId& account_id) override; |
+ void OnSessionStateChanged(session_manager::SessionState state) override; |
+ |
+ private: |
+ void Refresh(); |
+ |
+ void InitFromUserPrefs(); |
+ |
+ void PersistUserPrefs(); |
+ |
+ void NotifyStatusChanged(); |
+ |
+ // The observed session controller instance from which we know when to |
+ // initialize the NightLight settings from the user preferences. |
+ SessionController* const session_controller_; |
+ |
+ // The applied color temperature value when NightLight is turned ON. It's a |
+ // 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
|
+ float color_temperature_ = 0.5f; |
+ |
+ bool enabled_ = false; |
+ |
+ base::ObserverList<Observer> observers_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(NightLightController); |
+}; |
+ |
+} // namespace ash |
+ |
+#endif // ASH_SYSTEM_NIGHT_LIGHT_NIGHT_LIGHT_CONTROLLER_H_ |