icon_cacher.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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_TILES_ICON_CACHER_H_
  5. #define COMPONENTS_NTP_TILES_ICON_CACHER_H_
  6. #include "base/callback.h"
  7. #include "components/ntp_tiles/popular_sites.h"
  8. namespace ntp_tiles {
  9. // Ensures that Popular Sites icons and MostLikely icons are cached, downloading
  10. // and saving them if not.
  11. //
  12. // Does not provide any way to get a fetched favicon; use the FaviconService /
  13. // LargeIconService for that. All this interface guarantees is that
  14. // FaviconService will be able to get you an icon (if it exists).
  15. class IconCacher {
  16. public:
  17. virtual ~IconCacher() = default;
  18. // Fetches the icon if necessary. If a new icon was fetched, the optional
  19. // |icon_available| callback will be invoked.
  20. // If there are preliminary icons (e.g. provided by static resources), the
  21. // optional |preliminary_icon_available| callback will be invoked in addition.
  22. virtual void StartFetchPopularSites(
  23. PopularSites::Site site,
  24. base::OnceClosure icon_available,
  25. base::OnceClosure preliminary_icon_available) = 0;
  26. // Fetches the icon if necessary, then invokes |done| with true if it was
  27. // newly fetched (false if it was already cached or could not be fetched).
  28. virtual void StartFetchMostLikely(const GURL& page_url,
  29. base::OnceClosure icon_available) = 0;
  30. };
  31. } // namespace ntp_tiles
  32. #endif // COMPONENTS_NTP_TILES_ICON_CACHER_H_