OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef COMPONENTS_NTP_TILES_ICON_CACHER_IMPL_H_ | 5 #ifndef COMPONENTS_NTP_TILES_ICON_CACHER_IMPL_H_ |
6 #define COMPONENTS_NTP_TILES_ICON_CACHER_IMPL_H_ | 6 #define COMPONENTS_NTP_TILES_ICON_CACHER_IMPL_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/cancelable_callback.h" | 12 #include "base/cancelable_callback.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "base/task/cancelable_task_tracker.h" | 14 #include "base/task/cancelable_task_tracker.h" |
15 #include "components/ntp_tiles/icon_cacher.h" | 15 #include "components/ntp_tiles/icon_cacher.h" |
16 #include "components/ntp_tiles/popular_sites.h" | 16 #include "components/ntp_tiles/popular_sites.h" |
17 | 17 |
18 namespace favicon { | 18 namespace favicon { |
19 class FaviconService; | 19 class FaviconService; |
| 20 class LargeIconService; |
20 } // namespace favicon | 21 } // namespace favicon |
21 | 22 |
22 namespace favicon_base { | 23 namespace favicon_base { |
23 struct FaviconImageResult; | 24 struct FaviconImageResult; |
| 25 struct LargeIconResult; |
24 } // namespace favicon_base | 26 } // namespace favicon_base |
25 | 27 |
26 namespace gfx { | 28 namespace gfx { |
27 class Image; | 29 class Image; |
28 } // namespace gfx | 30 } // namespace gfx |
29 | 31 |
30 namespace image_fetcher { | 32 namespace image_fetcher { |
31 class ImageFetcher; | 33 class ImageFetcher; |
32 struct RequestMetadata; | 34 struct RequestMetadata; |
33 } // namespace image_fetcher | 35 } // namespace image_fetcher |
34 | 36 |
35 namespace ntp_tiles { | 37 namespace ntp_tiles { |
36 | 38 |
37 class IconCacherImpl : public IconCacher { | 39 class IconCacherImpl : public IconCacher { |
38 public: | 40 public: |
| 41 // TODO(jkrcal): Make this eventually use only LargeIconService. |
| 42 // crbug.com/696563 |
39 IconCacherImpl(favicon::FaviconService* favicon_service, | 43 IconCacherImpl(favicon::FaviconService* favicon_service, |
| 44 favicon::LargeIconService* large_icon_service, |
40 std::unique_ptr<image_fetcher::ImageFetcher> image_fetcher); | 45 std::unique_ptr<image_fetcher::ImageFetcher> image_fetcher); |
41 ~IconCacherImpl() override; | 46 ~IconCacherImpl() override; |
42 | 47 |
43 void StartFetch(PopularSites::Site site, | 48 void StartFetchPopularSites( |
44 const base::Closure& icon_available, | 49 PopularSites::Site site, |
45 const base::Closure& preliminary_icon_available) override; | 50 const base::Closure& icon_available, |
| 51 const base::Closure& preliminary_icon_available) override; |
| 52 void StartFetchMostLikely(const GURL& page_url, |
| 53 const base::Closure& icon_available) override; |
46 | 54 |
47 private: | 55 private: |
48 using CancelableImageCallback = | 56 using CancelableImageCallback = |
49 base::CancelableCallback<void(const gfx::Image&)>; | 57 base::CancelableCallback<void(const gfx::Image&)>; |
50 | 58 |
51 void OnGetFaviconImageForPageURLFinished( | 59 void OnGetFaviconImageForPageURLFinished( |
52 PopularSites::Site site, | 60 PopularSites::Site site, |
53 const base::Closure& icon_available, | 61 const base::Closure& icon_available, |
54 const base::Closure& preliminary_icon_available, | 62 const base::Closure& preliminary_icon_available, |
55 const favicon_base::FaviconImageResult& result); | 63 const favicon_base::FaviconImageResult& result); |
56 | 64 |
57 void OnFaviconDownloaded( | 65 void OnPopularSitesFaviconDownloaded( |
58 PopularSites::Site site, | 66 PopularSites::Site site, |
59 std::unique_ptr<CancelableImageCallback> preliminary_callback, | 67 std::unique_ptr<CancelableImageCallback> preliminary_callback, |
60 const base::Closure& icon_available, | 68 const base::Closure& icon_available, |
61 const std::string& id, | 69 const std::string& id, |
62 const gfx::Image& fetched_image, | 70 const gfx::Image& fetched_image, |
63 const image_fetcher::RequestMetadata& metadata); | 71 const image_fetcher::RequestMetadata& metadata); |
64 | 72 |
65 std::unique_ptr<CancelableImageCallback> MaybeProvideDefaultIcon( | 73 std::unique_ptr<CancelableImageCallback> MaybeProvideDefaultIcon( |
66 const PopularSites::Site& site, | 74 const PopularSites::Site& site, |
67 const base::Closure& icon_available); | 75 const base::Closure& icon_available); |
68 void SaveAndNotifyIconForSite(const PopularSites::Site& site, | 76 void SaveAndNotifyIconForSite(const PopularSites::Site& site, |
69 const base::Closure& icon_available, | 77 const base::Closure& icon_available, |
70 const gfx::Image& image); | 78 const gfx::Image& image); |
71 | 79 |
| 80 void OnGetLargeIconOrFallbackStyleFinished( |
| 81 const GURL& page_url, |
| 82 const base::Closure& icon_available, |
| 83 const favicon_base::LargeIconResult& result); |
| 84 |
| 85 void OnMostLikelyFaviconDownloaded(const base::Closure& icon_available, |
| 86 bool success); |
| 87 |
72 base::CancelableTaskTracker tracker_; | 88 base::CancelableTaskTracker tracker_; |
73 favicon::FaviconService* const favicon_service_; | 89 favicon::FaviconService* const favicon_service_; |
| 90 favicon::LargeIconService* const large_icon_service_; |
74 std::unique_ptr<image_fetcher::ImageFetcher> const image_fetcher_; | 91 std::unique_ptr<image_fetcher::ImageFetcher> const image_fetcher_; |
75 | 92 |
76 base::WeakPtrFactory<IconCacherImpl> weak_ptr_factory_; | 93 base::WeakPtrFactory<IconCacherImpl> weak_ptr_factory_; |
77 | 94 |
78 DISALLOW_COPY_AND_ASSIGN(IconCacherImpl); | 95 DISALLOW_COPY_AND_ASSIGN(IconCacherImpl); |
79 }; | 96 }; |
80 | 97 |
81 } // namespace ntp_tiles | 98 } // namespace ntp_tiles |
82 | 99 |
83 #endif // COMPONENTS_NTP_TILES_ICON_CACHER_IMPL_H_ | 100 #endif // COMPONENTS_NTP_TILES_ICON_CACHER_IMPL_H_ |
OLD | NEW |