| 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/public/cpp/ash_pref_names.h" | 7 #include "ash/public/cpp/ash_pref_names.h" |
| 8 #include "ash/session/session_controller.h" | 8 #include "ash/session/session_controller.h" |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 active_user_pref_service_ = Shell::Get()->GetActiveUserPrefService(); | 108 active_user_pref_service_ = Shell::Get()->GetActiveUserPrefService(); |
| 109 InitFromUserPrefs(); | 109 InitFromUserPrefs(); |
| 110 } | 110 } |
| 111 | 111 |
| 112 void NightLightController::Refresh() { | 112 void NightLightController::Refresh() { |
| 113 // TODO(afakhry): Add here refreshing of start and end times, when you | 113 // TODO(afakhry): Add here refreshing of start and end times, when you |
| 114 // implement the automatic schedule settings. | 114 // implement the automatic schedule settings. |
| 115 ApplyColorTemperatureToLayers( | 115 ApplyColorTemperatureToLayers( |
| 116 GetEnabled() ? GetColorTemperature() : 0.0f, | 116 GetEnabled() ? GetColorTemperature() : 0.0f, |
| 117 base::TimeDelta::FromSeconds(kManualToggleAnimationDurationSec)); | 117 base::TimeDelta::FromSeconds(kManualToggleAnimationDurationSec)); |
| 118 Shell::Get()->SetCursorCompositingEnabled(GetEnabled()); |
| 118 } | 119 } |
| 119 | 120 |
| 120 void NightLightController::StartWatchingPrefsChanges() { | 121 void NightLightController::StartWatchingPrefsChanges() { |
| 121 DCHECK(active_user_pref_service_); | 122 DCHECK(active_user_pref_service_); |
| 122 | 123 |
| 123 pref_change_registrar_ = base::MakeUnique<PrefChangeRegistrar>(); | 124 pref_change_registrar_ = base::MakeUnique<PrefChangeRegistrar>(); |
| 124 pref_change_registrar_->Init(active_user_pref_service_); | 125 pref_change_registrar_->Init(active_user_pref_service_); |
| 125 pref_change_registrar_->Add( | 126 pref_change_registrar_->Add( |
| 126 prefs::kNightLightEnabled, | 127 prefs::kNightLightEnabled, |
| 127 base::Bind(&NightLightController::OnEnabledPrefChanged, | 128 base::Bind(&NightLightController::OnEnabledPrefChanged, |
| (...skipping 25 matching lines...) Expand all Loading... |
| 153 Refresh(); | 154 Refresh(); |
| 154 NotifyStatusChanged(); | 155 NotifyStatusChanged(); |
| 155 } | 156 } |
| 156 | 157 |
| 157 void NightLightController::OnColorTemperaturePrefChanged() { | 158 void NightLightController::OnColorTemperaturePrefChanged() { |
| 158 DCHECK(active_user_pref_service_); | 159 DCHECK(active_user_pref_service_); |
| 159 Refresh(); | 160 Refresh(); |
| 160 } | 161 } |
| 161 | 162 |
| 162 } // namespace ash | 163 } // namespace ash |
| OLD | NEW |