#include "components/favicon/core/favicon_handler.h"
#include <cmath>
#include <utility>
#include <vector>
#include "base/containers/contains.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/logging.h"
#include "base/memory/ref_counted_memory.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h"
#include "base/ranges/algorithm.h"
#include "build/build_config.h"
#include "components/favicon/core/core_favicon_service.h"
#include "components/favicon_base/favicon_util.h"
#include "components/favicon_base/select_favicon_frames.h"
#include "skia/ext/image_operations.h"
#include "ui/gfx/codec/png_codec.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/gfx/image/image_util.h"
namespace favicon {
namespace {
const int kLargestIconSize = …;
bool HasExpiredOrIncompleteResult(
int desired_size_in_dip,
const std::vector<favicon_base::FaviconRawBitmapResult>& bitmap_results) { … }
bool HasValidResult(
const std::vector<favicon_base::FaviconRawBitmapResult>& bitmap_results) { … }
std::vector<int> GetDesiredPixelSizes(
FaviconDriverObserver::NotificationIconType handler_type) { … }
bool FaviconURLEquals(const FaviconURL& lhs, const FaviconURL& rhs) { … }
bool HasAnySize(const std::vector<gfx::Size>& icon_sizes) { … }
}
FaviconHandler::FaviconCandidate
FaviconHandler::FaviconCandidate::FromFaviconURL(
const favicon::FaviconURL& favicon_url,
const std::vector<int>& desired_pixel_sizes,
bool want_largest_icon) { … }
FaviconHandler::FaviconHandler(
CoreFaviconService* service,
Delegate* delegate,
FaviconDriverObserver::NotificationIconType handler_type)
: … { … }
FaviconHandler::~FaviconHandler() = default;
favicon_base::IconTypeSet FaviconHandler::GetIconTypesFromHandlerType(
FaviconDriverObserver::NotificationIconType handler_type) { … }
void FaviconHandler::FetchFavicon(const GURL& page_url, bool is_same_document) { … }
bool FaviconHandler::ShouldDownloadNextCandidate() const { … }
void FaviconHandler::SetFavicon(const GURL& icon_url,
const gfx::Image& image,
favicon_base::IconType icon_type) { … }
void FaviconHandler::MaybeDeleteFaviconMappings() { … }
void FaviconHandler::NotifyFaviconUpdated(
const std::vector<favicon_base::FaviconRawBitmapResult>&
favicon_bitmap_results) { … }
void FaviconHandler::NotifyFaviconUpdated(const GURL& icon_url,
favicon_base::IconType icon_type,
const gfx::Image& image) { … }
void FaviconHandler::OnUpdateCandidates(
const GURL& page_url,
const std::vector<FaviconURL>& candidates,
const GURL& manifest_url) { … }
void FaviconHandler::OnFaviconDataForManifestFromFaviconService(
const std::vector<favicon_base::FaviconRawBitmapResult>&
favicon_bitmap_results) { … }
void FaviconHandler::OnDidDownloadManifest(
const std::vector<FaviconURL>& candidates) { … }
void FaviconHandler::OnGotFinalIconURLCandidates(
const std::vector<FaviconURL>& candidates) { … }
int FaviconHandler::GetMaximalIconSize(
FaviconDriverObserver::NotificationIconType handler_type,
bool candidates_from_web_manifest) { … }
void FaviconHandler::OnGotInitialHistoryDataAndIconURLCandidates() { … }
void FaviconHandler::OnDidDownloadFavicon(
favicon_base::IconType icon_type,
int id,
int http_status_code,
const GURL& image_url,
const std::vector<SkBitmap>& bitmaps,
const std::vector<gfx::Size>& original_bitmap_sizes) { … }
const std::vector<GURL> FaviconHandler::GetIconURLs() const { … }
bool FaviconHandler::HasPendingTasksForTest() { … }
void FaviconHandler::OnFaviconDataForInitialURLFromFaviconService(
const std::vector<favicon_base::FaviconRawBitmapResult>&
favicon_bitmap_results) { … }
void FaviconHandler::DownloadCurrentCandidateOrAskFaviconService() { … }
void FaviconHandler::GetFaviconAndUpdateMappingsUnlessIncognito(
const GURL& icon_url,
favicon_base::IconType icon_type,
favicon_base::FaviconResultsCallback callback) { … }
void FaviconHandler::OnFaviconData(
const std::vector<favicon_base::FaviconRawBitmapResult>&
favicon_bitmap_results) { … }
void FaviconHandler::ScheduleImageDownload(const GURL& image_url,
favicon_base::IconType icon_type) { … }
}