Skip to content

Commit

Permalink
Rename NightLightController::GetEnabled().
Browse files Browse the repository at this point in the history
When NightLightControllerImpl inherits from ScheduledFeature in
an imminent CL, ScheduledFeature::GetEnabled() will have the
exact same name and signature as NightLightController::GetEnabled().
This simply renames the latter to avoid confusion and compiler
issues.

Bug: b:289276024
Change-Id: I34a4ab88cbe49f836bc23a34b00b81ff0c0366c1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4932924
Commit-Queue: Eric Sum <esum@google.com>
Reviewed-by: Ahmed Fakhry <afakhry@chromium.org>
Reviewed-by: David Padlipsky <dpad@google.com>
Cr-Commit-Position: refs/heads/main@{#1211713}
  • Loading branch information
esum26 authored and Chromium LUCI CQ committed Oct 18, 2023
1 parent b830442 commit 0ca0d3b
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 90 deletions.
2 changes: 1 addition & 1 deletion ash/public/cpp/night_light_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class ASH_PUBLIC_EXPORT NightLightController {
virtual void SetCurrentGeoposition(const SimpleGeoposition& position) = 0;

// Whether Night Light is enabled.
virtual bool GetEnabled() const = 0;
virtual bool IsNightLightEnabled() const = 0;

void AddObserver(Observer* observer);
void RemoveObserver(Observer* observer);
Expand Down
4 changes: 2 additions & 2 deletions ash/system/brightness/unified_brightness_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ UnifiedBrightnessView::UnifiedBrightnessView(
return;
}

const bool toggled = night_light_controller_->GetEnabled();
const bool toggled = night_light_controller_->IsNightLightEnabled();
night_light_button_ = AddChildView(std::make_unique<IconButton>(
base::BindRepeating(&UnifiedBrightnessView::OnNightLightButtonPressed,
base::Unretained(this)),
Expand Down Expand Up @@ -141,7 +141,7 @@ void UnifiedBrightnessView::OnNightLightButtonPressed() {
void UnifiedBrightnessView::UpdateNightLightButton() {
night_light_button_->SetEnabled(
TrayPopupUtils::CanShowNightLightFeatureTile());
const bool toggled = night_light_controller_->GetEnabled();
const bool toggled = night_light_controller_->IsNightLightEnabled();

// Sets `night_light_button_` toggle state to update its icon, icon color,
// and background color.
Expand Down
27 changes: 15 additions & 12 deletions ash/system/night_light/night_light_controller_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ void NightLightControllerImpl::SetCustomEndTime(TimeOfDay end_time) {
}

void NightLightControllerImpl::Toggle() {
SetEnabled(!GetEnabled(), AnimationDuration::kShort);
SetEnabled(!IsNightLightEnabled(), AnimationDuration::kShort);
}

void NightLightControllerImpl::OnDisplayConfigurationChanged() {
Expand All @@ -642,7 +642,8 @@ void NightLightControllerImpl::OnHostInitialized(aura::WindowTreeHost* host) {
// This newly initialized |host| could be of a newly added display, or of a
// newly created mirroring display (either for mirroring or unified). we need
// to apply the current temperature immediately without animation.
ApplyTemperatureToHost(host, GetEnabled() ? GetColorTemperature() : 0.0f);
ApplyTemperatureToHost(host,
IsNightLightEnabled() ? GetColorTemperature() : 0.0f);
}

void NightLightControllerImpl::OnActiveUserPrefServiceChanged(
Expand Down Expand Up @@ -705,7 +706,7 @@ void NightLightControllerImpl::SetCurrentGeoposition(
Refresh(/*did_schedule_change=*/true, keep_manual_toggles_during_schedules);
}

bool NightLightControllerImpl::GetEnabled() const {
bool NightLightControllerImpl::IsNightLightEnabled() const {
return active_user_pref_service_ &&
active_user_pref_service_->GetBoolean(prefs::kNightLightEnabled);
}
Expand Down Expand Up @@ -799,7 +800,7 @@ bool NightLightControllerImpl::MaybeRestoreSchedule() {
return false;

VLOG(1) << "Restoring a previous schedule.";
DCHECK_NE(GetEnabled(), target_state.target_status);
DCHECK_NE(IsNightLightEnabled(), target_state.target_status);
ScheduleNextToggle(target_state.target_time - delegate_->GetNow());
return true;
}
Expand All @@ -818,7 +819,7 @@ bool NightLightControllerImpl::UserHasEverDismissedAutoNightLightNotification()

void NightLightControllerImpl::ShowAutoNightLightNotification() {
DCHECK(features::IsAutoNightLightEnabled());
DCHECK(GetEnabled());
DCHECK(IsNightLightEnabled());
DCHECK(!UserHasEverDismissedAutoNightLightNotification());
DCHECK_EQ(ScheduleType::kSunsetToSunrise, GetScheduleType());

Expand Down Expand Up @@ -900,7 +901,8 @@ void NightLightControllerImpl::StoreCachedGeoposition(

void NightLightControllerImpl::RefreshDisplaysTemperature(
float color_temperature) {
const float new_temperature = GetEnabled() ? color_temperature : 0.0f;
const float new_temperature =
IsNightLightEnabled() ? color_temperature : 0.0f;
temperature_animation_->AnimateToNewValue(
new_temperature, animation_duration_ == AnimationDuration::kShort
? kManualAnimationDuration
Expand All @@ -915,7 +917,8 @@ void NightLightControllerImpl::RefreshDisplaysTemperature(

void NightLightControllerImpl::ReapplyColorTemperatures() {
DCHECK(temperature_animation_);
const float target_temperature = GetEnabled() ? GetColorTemperature() : 0.0f;
const float target_temperature =
IsNightLightEnabled() ? GetColorTemperature() : 0.0f;
if (temperature_animation_->is_animating()) {
// Do not interrupt an on-going animation towards the same target value.
if (temperature_animation_->target_temperature() == target_temperature)
Expand Down Expand Up @@ -981,7 +984,7 @@ void NightLightControllerImpl::InitFromUserPrefs() {

void NightLightControllerImpl::NotifyStatusChanged() {
for (auto& observer : observers_)
observer.OnNightLightEnabledChanged(GetEnabled());
observer.OnNightLightEnabledChanged(IsNightLightEnabled());
}

void NightLightControllerImpl::NotifyClientWithScheduleChange() {
Expand All @@ -990,7 +993,7 @@ void NightLightControllerImpl::NotifyClientWithScheduleChange() {
}

void NightLightControllerImpl::OnEnabledPrefChanged() {
const bool enabled = GetEnabled();
const bool enabled = IsNightLightEnabled();
VLOG(1) << "Enable state changed. New state: " << enabled << ".";
DCHECK(active_user_pref_service_);

Expand Down Expand Up @@ -1178,7 +1181,7 @@ void NightLightControllerImpl::RefreshScheduleTimer(
DCHECK_GE(start_time, now);
DCHECK_GE(end_time, now);

if (did_schedule_change && enable_now != GetEnabled()) {
if (did_schedule_change && enable_now != IsNightLightEnabled()) {
// If the change in the schedule introduces a change in the status, then
// calling SetEnabled() is all we need, since it will trigger a change in
// the user prefs to which we will respond by calling Refresh(). This will
Expand All @@ -1196,14 +1199,14 @@ void NightLightControllerImpl::RefreshScheduleTimer(
// wish and maintain the current status that they desire, but we schedule the
// status to be toggled according to the time that corresponds with the
// opposite status of the current one.
ScheduleNextToggle(GetEnabled() ? end_time - now : start_time - now);
ScheduleNextToggle(IsNightLightEnabled() ? end_time - now : start_time - now);
RefreshDisplaysTemperature(GetColorTemperature());
}

void NightLightControllerImpl::ScheduleNextToggle(base::TimeDelta delay) {
DCHECK(active_user_pref_service_);

const bool new_status = !GetEnabled();
const bool new_status = !IsNightLightEnabled();
const base::Time target_time = delegate_->GetNow() + delay;

per_user_schedule_target_state_[active_user_pref_service_] =
Expand Down
2 changes: 1 addition & 1 deletion ash/system/night_light/night_light_controller_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ class ASH_EXPORT NightLightControllerImpl

// ash::NightLightController:
void SetCurrentGeoposition(const SimpleGeoposition& position) override;
bool GetEnabled() const override;
bool IsNightLightEnabled() const override;

// chromeos::PowerManagerClient::Observer:
void SuspendDone(base::TimeDelta sleep_duration) override;
Expand Down
Loading

0 comments on commit 0ca0d3b

Please sign in to comment.