Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(466)

Unified Diff: ash/system/night_light/night_light_controller.h

Issue 2857103007: [Night Light] CL2: Ash and system tray work (Closed)
Patch Set: Update comment Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/shell.cc ('k') | ash/system/night_light/night_light_controller.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..0b0e5c1b070db9ecb04e833ddcf5c164d1e7b182
--- /dev/null
+++ b/ash/system/night_light/night_light_controller.h
@@ -0,0 +1,79 @@
+// 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;
+
+// Controls the NightLight feature that adjusts the color temperature of the
+// screen.
+class ASH_EXPORT NightLightController : public SessionObserver {
+ public:
+ class Observer {
+ public:
+ // Emitted when the NightLight status is changed.
+ virtual void OnNightLightEnabledChanged(bool enabled) = 0;
+
+ protected:
+ virtual ~Observer() {}
+ };
+
+ explicit NightLightController(SessionController* session_controller);
+ ~NightLightController() override;
+
+ static void RegisterPrefs(PrefRegistrySimple* registry);
+
+ 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);
+
+ // Set the screen color temperature. |temperature| should be a value from
+ // 0.0f (least warm) to 1.0f (most warm).
+ void SetColorTemperature(float temperature);
+
+ // ash::SessionObserver:
+ void OnActiveUserSessionChanged(const AccountId& account_id) 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, default display color) to 1.0f (most warm).
+ 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_
« no previous file with comments | « ash/shell.cc ('k') | ash/system/night_light/night_light_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698