blob: d581e6df3961a25b1fd9cf457f6a0b0a61dd39b3 [file] [log] [blame]
Avi Drissman3a215d1e2022-09-07 19:43:091// Copyright 2013 The Chromium Authors
James Cookb0bf8e82017-04-09 17:01:442// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef ASH_SYSTEM_BRIGHTNESS_CONTROL_DELEGATE_H_
6#define ASH_SYSTEM_BRIGHTNESS_CONTROL_DELEGATE_H_
7
Arthur Sonzognia98e4432023-11-28 18:15:018#include <optional>
9
Avi Drissman4de6dab2023-01-06 23:17:3510#include "base/functional/callback.h"
Cam Bickel43d91ef2024-04-05 20:56:1611#include "base/functional/callback_forward.h"
James Cookb0bf8e82017-04-09 17:01:4412
James Cookb0bf8e82017-04-09 17:01:4413namespace ash {
14
15// Delegate for controlling the brightness.
16class BrightnessControlDelegate {
17 public:
18 virtual ~BrightnessControlDelegate() {}
19
20 // Handles an accelerator-driven request to decrease or increase the screen
21 // brightness.
Longbo Wei43df3142022-09-14 21:19:1122 virtual void HandleBrightnessDown() = 0;
23 virtual void HandleBrightnessUp() = 0;
James Cookb0bf8e82017-04-09 17:01:4424
Cam Bickel681b7262024-04-17 16:28:4625 // Enum to represent the source of a brightness change, i.e. what triggered
26 // the brightness change.
27 enum class BrightnessChangeSource {
28 kUnknown = 0,
29 kQuickSettings = 1,
30 kSettingsApp = 2,
Cam Bickelb42c6772024-05-17 20:55:1431 kRestoredFromUserPref = 3,
32 kMaxValue = kRestoredFromUserPref,
Cam Bickel681b7262024-04-17 16:28:4633 };
34
Longbo Wei8f2f4fde2024-07-26 17:04:3335 // Enum to represent the source of a ambient light sensor change,
36 // Note that changing brightness can also disable the Ambient Light
37 // Sensor. This change is not directly made by calling the
38 // SetAmbientLightSensorEnabled function in the BrightnessControlDelegate in
39 // Chrome, it is handled in the platform.
40 enum class AmbientLightSensorEnabledChangeSource {
41 kSettingsApp = 0,
42 kRestoredFromUserPref = 1,
Longbo Wei910863b32024-08-03 00:01:4443 kSystemReenabled = 2,
44 kMaxValue = kSystemReenabled,
Longbo Wei8f2f4fde2024-07-26 17:04:3345 };
46
James Cookb0bf8e82017-04-09 17:01:4447 // Requests that the brightness be set to |percent|, in the range
48 // [0.0, 100.0]. |gradual| specifies whether the transition to the new
Cam Bickel681b7262024-04-17 16:28:4649 // brightness should be animated or instantaneous. |source| is required to
50 // indicate what is causing this brightness change.
51 virtual void SetBrightnessPercent(double percent,
52 bool gradual,
53 BrightnessChangeSource source) = 0;
James Cookb0bf8e82017-04-09 17:01:4454
55 // Asynchronously invokes |callback| with the current brightness, in the range
Hidehiko Abe181b2972017-10-30 06:43:5356 // [0.0, 100.0]. In case of error, it is called with nullopt.
James Cookb0bf8e82017-04-09 17:01:4457 virtual void GetBrightnessPercent(
Arthur Sonzognia98e4432023-11-28 18:15:0158 base::OnceCallback<void(std::optional<double>)> callback) = 0;
Cam Bickel8d3cd2c2024-04-03 17:36:0159
60 // Sets whether the ambient light sensor should be used in brightness
61 // calculations.
Longbo Wei8f2f4fde2024-07-26 17:04:3362 virtual void SetAmbientLightSensorEnabled(
63 bool enabled,
64 AmbientLightSensorEnabledChangeSource source) = 0;
Cam Bickel43d91ef2024-04-05 20:56:1665
Cam Bickel1dd22932024-05-01 19:08:0966 // Asynchronously invokes |callback| with true if the ambient light sensor is
67 // enabled (i.e. if the ambient light sensor is currently being used in
68 // brightness calculations). In case of error, |callback| will be run with
69 // nullopt.
70 virtual void GetAmbientLightSensorEnabled(
71 base::OnceCallback<void(std::optional<bool>)> callback) = 0;
72
Cam Bickel43d91ef2024-04-05 20:56:1673 // Asynchronously invokes |callback| with true if the device has at least one
74 // ambient light sensor. In case of error, |callback| will be run with
75 // nullopt.
76 virtual void HasAmbientLightSensor(
77 base::OnceCallback<void(std::optional<bool>)> callback) = 0;
James Cookb0bf8e82017-04-09 17:01:4478};
79
80} // namespace ash
81
82#endif // ASH_SYSTEM_BRIGHTNESS_CONTROL_DELEGATE_H_