Commit 4bc2788a authored by Ahmed Fakhry's avatar Ahmed Fakhry Committed by Commit Bot

Night Light unified tray label behavior

Rather than toggling Night Light on or off, clicking
the label should take the user to the display settings
page where Night Light can be adjusted.

BUG=859848
TEST=Manually

Change-Id: Ic1f15c6c953bfc8a38f94a7015dc7a3b877c404b
Reviewed-on: https://chromium-review.googlesource.com/1125338
Commit-Queue: Ahmed Fakhry <afakhry@chromium.org>
Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Cr-Commit-Position: refs/heads/master@{#572417}
parent 62007508
......@@ -9,13 +9,20 @@
#include "ash/session/session_controller.h"
#include "ash/shell.h"
#include "ash/strings/grit/ash_strings.h"
#include "ash/system/model/system_tray_model.h"
#include "ash/system/night_light/night_light_controller.h"
#include "ash/system/tray/tray_popup_utils.h"
#include "ash/system/unified/feature_pod_button.h"
#include "ash/system/unified/unified_system_tray_controller.h"
#include "ui/base/l10n/l10n_util.h"
namespace ash {
NightLightFeaturePodController::NightLightFeaturePodController() {}
NightLightFeaturePodController::NightLightFeaturePodController(
UnifiedSystemTrayController* tray_controller)
: tray_controller_(tray_controller) {
DCHECK(tray_controller_);
}
NightLightFeaturePodController::~NightLightFeaturePodController() = default;
......@@ -38,6 +45,14 @@ void NightLightFeaturePodController::OnIconPressed() {
UpdateButton();
}
void NightLightFeaturePodController::OnLabelPressed() {
DCHECK(features::IsNightLightEnabled());
if (TrayPopupUtils::CanOpenWebUISettings()) {
Shell::Get()->system_tray_model()->client_ptr()->ShowDisplaySettings();
tray_controller_->CloseBubble();
}
}
SystemTrayItemUmaType NightLightFeaturePodController::GetUmaType() const {
return SystemTrayItemUmaType::UMA_NIGHT_LIGHT;
}
......
......@@ -10,20 +10,26 @@
namespace ash {
class UnifiedSystemTrayController;
// Controller of a feature pod button that toggles night light mode.
class NightLightFeaturePodController : public FeaturePodControllerBase {
public:
NightLightFeaturePodController();
explicit NightLightFeaturePodController(
UnifiedSystemTrayController* tray_controller);
~NightLightFeaturePodController() override;
// FeaturePodControllerBase:
FeaturePodButton* CreateButton() override;
void OnIconPressed() override;
void OnLabelPressed() override;
SystemTrayItemUmaType GetUmaType() const override;
private:
void UpdateButton();
UnifiedSystemTrayController* const tray_controller_;
FeaturePodButton* button_ = nullptr;
DISALLOW_COPY_AND_ASSIGN(NightLightFeaturePodController);
......
......@@ -312,7 +312,7 @@ void UnifiedSystemTrayController::InitFeaturePods() {
AddFeaturePodItem(std::make_unique<BluetoothFeaturePodController>(this));
AddFeaturePodItem(std::make_unique<QuietModeFeaturePodController>(this));
AddFeaturePodItem(std::make_unique<RotationLockFeaturePodController>());
AddFeaturePodItem(std::make_unique<NightLightFeaturePodController>());
AddFeaturePodItem(std::make_unique<NightLightFeaturePodController>(this));
AddFeaturePodItem(std::make_unique<CastFeaturePodController>(this));
AddFeaturePodItem(std::make_unique<AccessibilityFeaturePodController>(this));
AddFeaturePodItem(std::make_unique<VPNFeaturePodController>(this));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment