fake_recent_apps_interaction_handler.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // Copyright 2021 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_COMPONENTS_PHONEHUB_FAKE_RECENT_APPS_INTERACTION_HANDLER_H_
  5. #define ASH_COMPONENTS_PHONEHUB_FAKE_RECENT_APPS_INTERACTION_HANDLER_H_
  6. #include <stdint.h>
  7. #include "ash/components/phonehub/notification.h"
  8. #include "ash/components/phonehub/recent_apps_interaction_handler.h"
  9. #include "ash/services/multidevice_setup/public/mojom/multidevice_setup.mojom.h"
  10. #include "base/time/time.h"
  11. namespace ash {
  12. namespace phonehub {
  13. class FakeRecentAppsInteractionHandler : public RecentAppsInteractionHandler {
  14. public:
  15. FakeRecentAppsInteractionHandler();
  16. FakeRecentAppsInteractionHandler(const FakeRecentAppsInteractionHandler&) =
  17. delete;
  18. FakeRecentAppsInteractionHandler* operator=(
  19. const FakeRecentAppsInteractionHandler&) = delete;
  20. ~FakeRecentAppsInteractionHandler() override;
  21. void OnFeatureStateChanged(
  22. multidevice_setup::mojom::FeatureState feature_state);
  23. size_t HandledRecentAppsCount(const std::string& package_name) const {
  24. return package_name_to_click_count_.at(package_name);
  25. }
  26. size_t recent_app_click_observer_count() const {
  27. return recent_app_click_observer_count_;
  28. }
  29. void NotifyRecentAppClicked(
  30. const Notification::AppMetadata& app_metadata) override;
  31. void AddRecentAppClickObserver(RecentAppClickObserver* observer) override;
  32. void RemoveRecentAppClickObserver(RecentAppClickObserver* observer) override;
  33. void NotifyRecentAppAddedOrUpdated(
  34. const Notification::AppMetadata& app_metadata,
  35. base::Time last_accessed_timestamp) override;
  36. std::vector<Notification::AppMetadata> FetchRecentAppMetadataList() override;
  37. void SetStreamableApps(const proto::StreamableApps& streamable_apps) override;
  38. private:
  39. void ComputeAndUpdateUiState();
  40. size_t recent_app_click_observer_count_ = 0;
  41. multidevice_setup::mojom::FeatureState feature_state_ =
  42. multidevice_setup::mojom::FeatureState::kDisabledByUser;
  43. std::vector<std::pair<Notification::AppMetadata, base::Time>>
  44. recent_apps_metadata_;
  45. std::map<std::string, size_t> package_name_to_click_count_;
  46. };
  47. } // namespace phonehub
  48. } // namespace ash
  49. #endif // ASH_COMPONENTS_PHONEHUB_FAKE_RECENT_APPS_INTERACTION_HANDLER_H_