OLD | NEW |
---|---|
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ash/system/night_light/night_light_controller.h" | 5 #include "ash/system/night_light/night_light_controller.h" |
6 | 6 |
7 #include "ash/ash_switches.h" | |
7 #include "ash/public/cpp/ash_pref_names.h" | 8 #include "ash/public/cpp/ash_pref_names.h" |
8 #include "ash/session/session_controller.h" | 9 #include "ash/session/session_controller.h" |
9 #include "ash/shell.h" | 10 #include "ash/shell.h" |
11 #include "base/command_line.h" | |
10 #include "base/time/time.h" | 12 #include "base/time/time.h" |
11 #include "components/prefs/pref_registry_simple.h" | 13 #include "components/prefs/pref_registry_simple.h" |
12 #include "components/prefs/pref_service.h" | 14 #include "components/prefs/pref_service.h" |
13 #include "ui/compositor/layer.h" | 15 #include "ui/compositor/layer.h" |
14 #include "ui/compositor/scoped_layer_animation_settings.h" | 16 #include "ui/compositor/scoped_layer_animation_settings.h" |
15 | 17 |
16 namespace ash { | 18 namespace ash { |
17 | 19 |
18 namespace { | 20 namespace { |
19 | 21 |
(...skipping 30 matching lines...) Expand all Loading... | |
50 SessionController* session_controller) | 52 SessionController* session_controller) |
51 : session_controller_(session_controller) { | 53 : session_controller_(session_controller) { |
52 session_controller_->AddObserver(this); | 54 session_controller_->AddObserver(this); |
53 } | 55 } |
54 | 56 |
55 NightLightController::~NightLightController() { | 57 NightLightController::~NightLightController() { |
56 session_controller_->RemoveObserver(this); | 58 session_controller_->RemoveObserver(this); |
57 } | 59 } |
58 | 60 |
59 // static | 61 // static |
62 bool NightLightController::IsFeatureEnabled() { | |
63 return base::CommandLine::ForCurrentProcess()->HasSwitch( | |
64 ash::switches::kAshEnableNightLight); | |
65 } | |
66 | |
67 // static | |
68 void NightLightController::EnableFeatureForTesting() { | |
69 base::CommandLine::ForCurrentProcess()->AppendSwitch( | |
James Cook
2017/06/02 23:40:05
nit: I think it would be better to do this in the
afakhry
2017/06/03 00:09:03
Done.
| |
70 ash::switches::kAshEnableNightLight); | |
71 } | |
72 | |
73 // static | |
60 void NightLightController::RegisterPrefs(PrefRegistrySimple* registry) { | 74 void NightLightController::RegisterPrefs(PrefRegistrySimple* registry) { |
61 registry->RegisterBooleanPref(prefs::kNightLightEnabled, false); | 75 registry->RegisterBooleanPref(prefs::kNightLightEnabled, false); |
62 registry->RegisterDoublePref(prefs::kNightLightTemperature, | 76 registry->RegisterDoublePref(prefs::kNightLightTemperature, |
63 kDefaultColorTemperature); | 77 kDefaultColorTemperature); |
64 } | 78 } |
65 | 79 |
66 void NightLightController::AddObserver(Observer* observer) { | 80 void NightLightController::AddObserver(Observer* observer) { |
67 observers_.AddObserver(observer); | 81 observers_.AddObserver(observer); |
68 } | 82 } |
69 | 83 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
154 Refresh(); | 168 Refresh(); |
155 NotifyStatusChanged(); | 169 NotifyStatusChanged(); |
156 } | 170 } |
157 | 171 |
158 void NightLightController::OnColorTemperaturePrefChanged() { | 172 void NightLightController::OnColorTemperaturePrefChanged() { |
159 DCHECK(active_user_pref_service_); | 173 DCHECK(active_user_pref_service_); |
160 Refresh(); | 174 Refresh(); |
161 } | 175 } |
162 | 176 |
163 } // namespace ash | 177 } // namespace ash |
OLD | NEW |