Chromium Code Reviews| 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 <map> | |
| 8 #include <memory> | 9 #include <memory> |
| 9 #include <string> | 10 #include <string> |
| 10 | 11 |
| 11 #include "base/callback.h" | 12 #include "base/callback.h" |
| 12 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 13 #include "base/task/cancelable_task_tracker.h" | 14 #include "base/task/cancelable_task_tracker.h" |
| 14 #include "components/ntp_tiles/icon_cacher.h" | 15 #include "components/ntp_tiles/icon_cacher.h" |
| 15 #include "components/ntp_tiles/popular_sites.h" | 16 #include "components/ntp_tiles/popular_sites.h" |
| 16 | 17 |
| 17 namespace favicon { | 18 namespace favicon { |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 33 namespace ntp_tiles { | 34 namespace ntp_tiles { |
| 34 | 35 |
| 35 class IconCacherImpl : public IconCacher { | 36 class IconCacherImpl : public IconCacher { |
| 36 public: | 37 public: |
| 37 IconCacherImpl(favicon::FaviconService* favicon_service, | 38 IconCacherImpl(favicon::FaviconService* favicon_service, |
| 38 std::unique_ptr<image_fetcher::ImageFetcher> image_fetcher); | 39 std::unique_ptr<image_fetcher::ImageFetcher> image_fetcher); |
| 39 ~IconCacherImpl() override; | 40 ~IconCacherImpl() override; |
| 40 | 41 |
| 41 void StartFetch(PopularSites::Site site, | 42 void StartFetch(PopularSites::Site site, |
| 42 const base::Callback<void(bool)>& done) override; | 43 const base::Callback<void(bool)>& done) override; |
| 44 void AddDefaultImage(const PopularSites::Site& site, | |
| 45 int image_resource_id) override; | |
| 43 | 46 |
| 44 private: | 47 private: |
| 48 struct DefaultIcon; | |
| 49 | |
| 45 void OnGetFaviconImageForPageURLFinished( | 50 void OnGetFaviconImageForPageURLFinished( |
| 46 PopularSites::Site site, | 51 PopularSites::Site site, |
| 47 const base::Callback<void(bool)>& done, | 52 const base::Callback<void(bool)>& done, |
| 48 const favicon_base::FaviconImageResult& result); | 53 const favicon_base::FaviconImageResult& result); |
| 49 | 54 |
| 50 void OnFaviconDownloaded(PopularSites::Site site, | 55 void OnFaviconDownloaded(PopularSites::Site site, |
| 51 const base::Callback<void(bool)>& done, | 56 const base::Callback<void(bool)>& done, |
| 52 const std::string& id, | 57 const std::string& id, |
| 53 const gfx::Image& fetched_image); | 58 const gfx::Image& fetched_image); |
| 54 | 59 |
| 60 bool ProvideDefaultIcon(const PopularSites::Site& site); | |
| 61 void SaveIconForSite(const PopularSites::Site& site, const gfx::Image image); | |
| 62 | |
| 55 base::CancelableTaskTracker tracker_; | 63 base::CancelableTaskTracker tracker_; |
| 56 favicon::FaviconService* const favicon_service_; | 64 favicon::FaviconService* const favicon_service_; |
| 57 std::unique_ptr<image_fetcher::ImageFetcher> const image_fetcher_; | 65 std::unique_ptr<image_fetcher::ImageFetcher> const image_fetcher_; |
| 66 std::map<const std::string, DefaultIcon> default_icons_; | |
|
sfiera
2017/02/16 11:14:22
Instead of having a map here, could PopularSites::
fhorschig
2017/02/16 17:06:41
Yes. It has now and the default resource ID is -1.
| |
| 58 | 67 |
| 59 DISALLOW_COPY_AND_ASSIGN(IconCacherImpl); | 68 DISALLOW_COPY_AND_ASSIGN(IconCacherImpl); |
| 60 }; | 69 }; |
| 61 | 70 |
| 62 } // namespace ntp_tiles | 71 } // namespace ntp_tiles |
| 63 | 72 |
| 64 #endif // COMPONENTS_NTP_TILES_ICON_CACHER_IMPL_H_ | 73 #endif // COMPONENTS_NTP_TILES_ICON_CACHER_IMPL_H_ |
| OLD | NEW |