gesture_education_notification_controller.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. #ifndef ASH_SYSTEM_GESTURE_EDUCATION_GESTURE_EDUCATION_NOTIFICATION_CONTROLLER_H_
  5. #define ASH_SYSTEM_GESTURE_EDUCATION_GESTURE_EDUCATION_NOTIFICATION_CONTROLLER_H_
  6. #include <string>
  7. #include "ash/ash_export.h"
  8. #include "ash/public/cpp/session/session_observer.h"
  9. #include "ash/public/cpp/tablet_mode_observer.h"
  10. #include "ash/wm/tablet_mode/tablet_mode_controller.h"
  11. #include "base/memory/weak_ptr.h"
  12. #include "base/scoped_observation.h"
  13. class PrefRegistrySimple;
  14. namespace ash {
  15. // Controller class to manage gesture education notification. This notification
  16. // shows up once to provide the user with information about new gestures added
  17. // to chrome os for easier navigation.
  18. class ASH_EXPORT GestureEducationNotificationController
  19. : public SessionObserver,
  20. public TabletModeObserver {
  21. public:
  22. GestureEducationNotificationController();
  23. ~GestureEducationNotificationController() override;
  24. // Shows the gesture education notification if it needs to be shown.
  25. void MaybeShowNotification();
  26. // SessionObserver:
  27. void OnActiveUserPrefServiceChanged(PrefService* pref_service) override;
  28. void OnSessionStateChanged(session_manager::SessionState state) override;
  29. // TabletModeObserver:
  30. void OnTabletModeStarted() override;
  31. void OnTabletControllerDestroyed() override;
  32. // See Shell::RegisterProfilePrefs().
  33. static void RegisterProfilePrefs(PrefRegistrySimple* registry, bool for_test);
  34. private:
  35. friend class GestureEducationNotificationControllerTest;
  36. void GenerateGestureEducationNotification();
  37. std::u16string GetNotificationTitle() const;
  38. std::u16string GetNotificationMessage() const;
  39. void HandleNotificationClick();
  40. void ResetPrefForTest();
  41. base::ScopedObservation<TabletModeController, TabletModeObserver>
  42. tablet_mode_observation_{this};
  43. PrefService* active_user_prefs_ = nullptr; // Not owned.
  44. static const char kNotificationId[];
  45. base::WeakPtrFactory<GestureEducationNotificationController>
  46. weak_ptr_factory_{this};
  47. };
  48. } // namespace ash
  49. #endif // ASH_SYSTEM_GESTURE_EDUCATION_GESTURE_EDUCATION_NOTIFICATION_CONTROLLER_H_