fake_content_suggestions_provider_observer.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // Copyright 2017 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 COMPONENTS_NTP_SNIPPETS_FAKE_CONTENT_SUGGESTIONS_PROVIDER_OBSERVER_H_
  5. #define COMPONENTS_NTP_SNIPPETS_FAKE_CONTENT_SUGGESTIONS_PROVIDER_OBSERVER_H_
  6. #include <map>
  7. #include <vector>
  8. #include "components/ntp_snippets/category.h"
  9. #include "components/ntp_snippets/content_suggestion.h"
  10. #include "components/ntp_snippets/content_suggestions_provider.h"
  11. namespace ntp_snippets {
  12. class FakeContentSuggestionsProviderObserver final
  13. : public ContentSuggestionsProvider::Observer {
  14. public:
  15. FakeContentSuggestionsProviderObserver();
  16. FakeContentSuggestionsProviderObserver(
  17. const FakeContentSuggestionsProviderObserver&) = delete;
  18. FakeContentSuggestionsProviderObserver& operator=(
  19. const FakeContentSuggestionsProviderObserver&) = delete;
  20. ~FakeContentSuggestionsProviderObserver();
  21. void OnNewSuggestions(ContentSuggestionsProvider* provider,
  22. Category category,
  23. std::vector<ContentSuggestion> suggestions) override;
  24. void OnCategoryStatusChanged(ContentSuggestionsProvider* provider,
  25. Category category,
  26. CategoryStatus new_status) override;
  27. void OnSuggestionInvalidated(
  28. ContentSuggestionsProvider* provider,
  29. const ContentSuggestion::ID& suggestion_id) override;
  30. const std::map<Category, CategoryStatus, Category::CompareByID>& statuses()
  31. const;
  32. CategoryStatus StatusForCategory(Category category) const;
  33. const std::vector<ContentSuggestion>& SuggestionsForCategory(
  34. Category category);
  35. private:
  36. std::map<Category, CategoryStatus, Category::CompareByID> statuses_;
  37. std::map<Category, std::vector<ContentSuggestion>, Category::CompareByID>
  38. suggestions_;
  39. };
  40. } // namespace ntp_snippets
  41. #endif // COMPONENTS_NTP_SNIPPETS_FAKE_CONTENT_SUGGESTIONS_PROVIDER_OBSERVER_H_