#include "components/ntp_tiles/icon_cacher_impl.h"
#include <utility>
#include "base/functional/bind.h"
#include "base/metrics/field_trial_params.h"
#include "base/metrics/histogram_macros.h"
#include "components/favicon/core/favicon_service.h"
#include "components/favicon/core/favicon_util.h"
#include "components/favicon/core/large_icon_service.h"
#include "components/favicon_base/fallback_icon_style.h"
#include "components/favicon_base/favicon_types.h"
#include "components/favicon_base/favicon_util.h"
#include "components/image_fetcher/core/image_decoder.h"
#include "components/image_fetcher/core/image_fetcher.h"
#include "components/ntp_tiles/features.h"
#include "net/traffic_annotation/network_traffic_annotation.h"
#include "services/data_decoder/public/cpp/data_decoder.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/image/image.h"
#include "url/gurl.h"
namespace ntp_tiles {
namespace {
constexpr int kDesiredFrameSize = …;
constexpr int kDefaultTileIconMinSizePx = …;
const char kImageFetcherUmaClient[] = …;
constexpr char kTileIconMinSizePxFieldParam[] = …;
favicon_base::IconType IconType(const PopularSites::Site& site) { … }
const GURL& IconURL(const PopularSites::Site& site) { … }
bool HasResultDefaultBackgroundColor(
const favicon_base::LargeIconResult& result) { … }
int GetMinimumFetchingSizeForChromeSuggestionsFaviconsFromServer() { … }
}
IconCacherImpl::IconCacherImpl(
favicon::FaviconService* favicon_service,
favicon::LargeIconService* large_icon_service,
std::unique_ptr<image_fetcher::ImageFetcher> image_fetcher,
std::unique_ptr<data_decoder::DataDecoder> data_decoder)
: … { … }
IconCacherImpl::~IconCacherImpl() = default;
void IconCacherImpl::StartFetchPopularSites(
PopularSites::Site site,
base::OnceClosure icon_available,
base::OnceClosure preliminary_icon_available) { … }
void IconCacherImpl::OnGetFaviconImageForPageURLFinished(
PopularSites::Site site,
base::OnceClosure preliminary_icon_available,
const favicon_base::FaviconImageResult& result) { … }
void IconCacherImpl::OnPopularSitesFaviconDownloaded(
PopularSites::Site site,
std::unique_ptr<CancelableImageCallback> preliminary_callback,
const gfx::Image& fetched_image,
const image_fetcher::RequestMetadata& metadata) { … }
void IconCacherImpl::SaveAndNotifyDefaultIconForSite(
const PopularSites::Site& site,
base::OnceClosure preliminary_icon_available,
const gfx::Image& image) { … }
void IconCacherImpl::SaveIconForSite(const PopularSites::Site& site,
const gfx::Image& image) { … }
std::unique_ptr<IconCacherImpl::CancelableImageCallback>
IconCacherImpl::MaybeProvideDefaultIcon(
const PopularSites::Site& site,
base::OnceClosure preliminary_icon_available) { … }
void IconCacherImpl::StartFetchMostLikely(const GURL& page_url,
base::OnceClosure icon_available) { … }
void IconCacherImpl::OnGetLargeIconOrFallbackStyleFinished(
const GURL& page_url,
const favicon_base::LargeIconResult& result) { … }
void IconCacherImpl::OnMostLikelyFaviconDownloaded(
const GURL& request_url,
favicon_base::GoogleFaviconServerRequestStatus status) { … }
bool IconCacherImpl::StartRequest(const GURL& request_url,
base::OnceClosure icon_available) { … }
void IconCacherImpl::FinishRequestAndNotifyIconAvailable(
const GURL& request_url,
bool newly_available) { … }
}