1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47
   48
   49
   50
   51
   52
   53
   54
   55
   56
   57
   58
   59
   60

ash / system / keyboard_brightness / keyboard_backlight_color_nudge_controller.h [blame]

// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef ASH_SYSTEM_KEYBOARD_BRIGHTNESS_KEYBOARD_BACKLIGHT_COLOR_NUDGE_CONTROLLER_H_
#define ASH_SYSTEM_KEYBOARD_BRIGHTNESS_KEYBOARD_BACKLIGHT_COLOR_NUDGE_CONTROLLER_H_

#include "ash/ash_export.h"
#include "ash/controls/contextual_nudge.h"
#include "base/memory/raw_ptr.h"
#include "base/timer/timer.h"

namespace views {
class View;
}  // namespace views

namespace ash {

// Controller to manage keyboard backlight color education nudge.
class ASH_EXPORT KeyboardBacklightColorNudgeController {
 public:
  KeyboardBacklightColorNudgeController();

  KeyboardBacklightColorNudgeController(
      const KeyboardBacklightColorNudgeController&) = delete;
  KeyboardBacklightColorNudgeController& operator=(
      const KeyboardBacklightColorNudgeController&) = delete;

  ~KeyboardBacklightColorNudgeController();

  // Determines whether the education nudge for wallpaper extracted color in the
  // personalization hub can be shown.
  static bool ShouldShowWallpaperColorNudge();

  // Called when the wallpaper color nudge is shown.
  static void HandleWallpaperColorNudgeShown();

  // Determines whether the education nudge can be shown and shows it.
  void MaybeShowEducationNudge(views::View* keyboard_brightness_slider_view);

  void CloseEducationNudge();

  // Called when the user has manually set the color.
  void SetUserPerformedAction();

 private:
  // Starts auto close timer.
  void StartAutoCloseTimer();

  base::OneShotTimer autoclose_;

  raw_ptr<ContextualNudge, DanglingUntriaged> education_nudge_ = nullptr;

  base::WeakPtrFactory<KeyboardBacklightColorNudgeController> weak_factory_{
      this};
};

}  // namespace ash

#endif  // ASH_SYSTEM_KEYBOARD_BRIGHTNESS_KEYBOARD_BACKLIGHT_COLOR_NUDGE_CONTROLLER_H_