Ahmed Mehfooz | d618d6b | 2020-02-29 01:46:30 | [diff] [blame] | 1 | // 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örrie | ad587c3 | 2021-03-11 14:09:27 | [diff] [blame] | 8 | #include <string> |
| 9 | |
Ahmed Mehfooz | d618d6b | 2020-02-29 01:46:30 | [diff] [blame] | 10 | #include "ash/ash_export.h" |
Mitsuru Oshima | e3e29b3 | 2020-07-07 17:29:17 | [diff] [blame] | 11 | #include "ash/public/cpp/session/session_observer.h" |
Ahmed Mehfooz | ccd31e1 | 2020-05-12 01:59:11 | [diff] [blame] | 12 | #include "ash/public/cpp/tablet_mode_observer.h" |
Ahmed Mehfooz | ccd31e1 | 2020-05-12 01:59:11 | [diff] [blame] | 13 | #include "ash/wm/tablet_mode/tablet_mode_controller.h" |
Ahmed Mehfooz | d618d6b | 2020-02-29 01:46:30 | [diff] [blame] | 14 | #include "base/macros.h" |
| 15 | #include "base/memory/weak_ptr.h" |
| 16 | #include "base/optional.h" |
Sigurdur Asgeirsson | e592c48 | 2021-01-28 16:17:29 | [diff] [blame] | 17 | #include "base/scoped_observation.h" |
Ahmed Mehfooz | d618d6b | 2020-02-29 01:46:30 | [diff] [blame] | 18 | #include "base/strings/string16.h" |
Ahmed Mehfooz | d618d6b | 2020-02-29 01:46:30 | [diff] [blame] | 19 | |
| 20 | class PrefRegistrySimple; |
| 21 | |
| 22 | namespace 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. |
| 27 | class ASH_EXPORT GestureEducationNotificationController |
Ahmed Mehfooz | ccd31e1 | 2020-05-12 01:59:11 | [diff] [blame] | 28 | : public SessionObserver, |
| 29 | public TabletModeObserver { |
Ahmed Mehfooz | d618d6b | 2020-02-29 01:46:30 | [diff] [blame] | 30 | public: |
| 31 | GestureEducationNotificationController(); |
| 32 | ~GestureEducationNotificationController() override; |
| 33 | |
Ahmed Mehfooz | ccd31e1 | 2020-05-12 01:59:11 | [diff] [blame] | 34 | // Shows the gesture education notification if it needs to be shown. |
| 35 | void MaybeShowNotification(); |
| 36 | |
Ahmed Mehfooz | d618d6b | 2020-02-29 01:46:30 | [diff] [blame] | 37 | // SessionObserver: |
| 38 | void OnActiveUserPrefServiceChanged(PrefService* pref_service) override; |
Ahmed Mehfooz | ccd31e1 | 2020-05-12 01:59:11 | [diff] [blame] | 39 | void OnSessionStateChanged(session_manager::SessionState state) override; |
| 40 | |
| 41 | // TabletModeObserver: |
| 42 | void OnTabletModeStarted() override; |
| 43 | void OnTabletControllerDestroyed() override; |
Ahmed Mehfooz | d618d6b | 2020-02-29 01:46:30 | [diff] [blame] | 44 | |
| 45 | // See Shell::RegisterProfilePrefs(). |
Ahmed Mehfooz | ccd31e1 | 2020-05-12 01:59:11 | [diff] [blame] | 46 | static void RegisterProfilePrefs(PrefRegistrySimple* registry, bool for_test); |
Ahmed Mehfooz | d618d6b | 2020-02-29 01:46:30 | [diff] [blame] | 47 | |
| 48 | private: |
Ahmed Mehfooz | ccd31e1 | 2020-05-12 01:59:11 | [diff] [blame] | 49 | friend class GestureEducationNotificationControllerTest; |
| 50 | |
Ahmed Mehfooz | d618d6b | 2020-02-29 01:46:30 | [diff] [blame] | 51 | void GenerateGestureEducationNotification(); |
Jan Wilken Dörrie | 85285b0 | 2021-03-11 23:38:47 | [diff] [blame^] | 52 | std::u16string GetNotificationTitle() const; |
| 53 | std::u16string GetNotificationMessage() const; |
Ahmed Mehfooz | d618d6b | 2020-02-29 01:46:30 | [diff] [blame] | 54 | void HandleNotificationClick(); |
Ahmed Mehfooz | d618d6b | 2020-02-29 01:46:30 | [diff] [blame] | 55 | |
Ahmed Mehfooz | ccd31e1 | 2020-05-12 01:59:11 | [diff] [blame] | 56 | void ResetPrefForTest(); |
| 57 | |
Sigurdur Asgeirsson | e592c48 | 2021-01-28 16:17:29 | [diff] [blame] | 58 | base::ScopedObservation<TabletModeController, TabletModeObserver> |
| 59 | tablet_mode_observation_{this}; |
Ahmed Mehfooz | ccd31e1 | 2020-05-12 01:59:11 | [diff] [blame] | 60 | |
| 61 | PrefService* active_user_prefs_ = nullptr; // Not owned. |
| 62 | |
| 63 | static const char kNotificationId[]; |
Ahmed Mehfooz | d618d6b | 2020-02-29 01:46:30 | [diff] [blame] | 64 | |
| 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_ |