[go: nahoru, domu]

blob: dc6f3873ac194f291f545a57064d7186c9e81cc4 [file] [log] [blame]
Ahmed Mehfoozd618d6b2020-02-29 01:46:301// Copyright 2020 The Chromium Authors. All rights reserved.
2// 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_GESTURE_EDUCATION_GESTURE_EDUCATION_NOTIFICATION_CONTROLLER_H_
6#define ASH_SYSTEM_GESTURE_EDUCATION_GESTURE_EDUCATION_NOTIFICATION_CONTROLLER_H_
7
Jan Wilken Dörriead587c32021-03-11 14:09:278#include <string>
9
Ahmed Mehfoozd618d6b2020-02-29 01:46:3010#include "ash/ash_export.h"
Mitsuru Oshimae3e29b32020-07-07 17:29:1711#include "ash/public/cpp/session/session_observer.h"
Ahmed Mehfoozccd31e12020-05-12 01:59:1112#include "ash/public/cpp/tablet_mode_observer.h"
Ahmed Mehfoozccd31e12020-05-12 01:59:1113#include "ash/wm/tablet_mode/tablet_mode_controller.h"
Ahmed Mehfoozd618d6b2020-02-29 01:46:3014#include "base/macros.h"
15#include "base/memory/weak_ptr.h"
16#include "base/optional.h"
Sigurdur Asgeirssone592c482021-01-28 16:17:2917#include "base/scoped_observation.h"
Ahmed Mehfoozd618d6b2020-02-29 01:46:3018#include "base/strings/string16.h"
Ahmed Mehfoozd618d6b2020-02-29 01:46:3019
20class PrefRegistrySimple;
21
22namespace ash {
23
24// Controller class to manage gesture education notification. This notification
25// shows up once to provide the user with information about new gestures added
26// to chrome os for easier navigation.
27class ASH_EXPORT GestureEducationNotificationController
Ahmed Mehfoozccd31e12020-05-12 01:59:1128 : public SessionObserver,
29 public TabletModeObserver {
Ahmed Mehfoozd618d6b2020-02-29 01:46:3030 public:
31 GestureEducationNotificationController();
32 ~GestureEducationNotificationController() override;
33
Ahmed Mehfoozccd31e12020-05-12 01:59:1134 // Shows the gesture education notification if it needs to be shown.
35 void MaybeShowNotification();
36
Ahmed Mehfoozd618d6b2020-02-29 01:46:3037 // SessionObserver:
38 void OnActiveUserPrefServiceChanged(PrefService* pref_service) override;
Ahmed Mehfoozccd31e12020-05-12 01:59:1139 void OnSessionStateChanged(session_manager::SessionState state) override;
40
41 // TabletModeObserver:
42 void OnTabletModeStarted() override;
43 void OnTabletControllerDestroyed() override;
Ahmed Mehfoozd618d6b2020-02-29 01:46:3044
45 // See Shell::RegisterProfilePrefs().
Ahmed Mehfoozccd31e12020-05-12 01:59:1146 static void RegisterProfilePrefs(PrefRegistrySimple* registry, bool for_test);
Ahmed Mehfoozd618d6b2020-02-29 01:46:3047
48 private:
Ahmed Mehfoozccd31e12020-05-12 01:59:1149 friend class GestureEducationNotificationControllerTest;
50
Ahmed Mehfoozd618d6b2020-02-29 01:46:3051 void GenerateGestureEducationNotification();
Jan Wilken Dörrie85285b02021-03-11 23:38:4752 std::u16string GetNotificationTitle() const;
53 std::u16string GetNotificationMessage() const;
Ahmed Mehfoozd618d6b2020-02-29 01:46:3054 void HandleNotificationClick();
Ahmed Mehfoozd618d6b2020-02-29 01:46:3055
Ahmed Mehfoozccd31e12020-05-12 01:59:1156 void ResetPrefForTest();
57
Sigurdur Asgeirssone592c482021-01-28 16:17:2958 base::ScopedObservation<TabletModeController, TabletModeObserver>
59 tablet_mode_observation_{this};
Ahmed Mehfoozccd31e12020-05-12 01:59:1160
61 PrefService* active_user_prefs_ = nullptr; // Not owned.
62
63 static const char kNotificationId[];
Ahmed Mehfoozd618d6b2020-02-29 01:46:3064
65 base::WeakPtrFactory<GestureEducationNotificationController>
66 weak_ptr_factory_{this};
67};
68
69} // namespace ash
70
71#endif // ASH_SYSTEM_GESTURE_EDUCATION_GESTURE_EDUCATION_NOTIFICATION_CONTROLLER_H_