Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Unified Diff: components/favicon/core/favicon_handler.h

Issue 2799273002: Add support to process favicons from Web Manifests (Closed)
Patch Set: Browsertest comments addressed. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/favicon/core/favicon_driver_impl.cc ('k') | components/favicon/core/favicon_handler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/favicon/core/favicon_handler.h
diff --git a/components/favicon/core/favicon_handler.h b/components/favicon/core/favicon_handler.h
index 0e579b3ceaf97bf429979b23590f36a032deb1c5..6199880fbb45f53a156bccefb55d8a811a41d602 100644
--- a/components/favicon/core/favicon_handler.h
+++ b/components/favicon/core/favicon_handler.h
@@ -23,10 +23,16 @@
class SkBitmap;
+namespace base {
+struct Feature;
+} // namespace base
+
namespace favicon {
class FaviconService;
+extern const base::Feature kFaviconsFromWebManifest;
+
// FaviconHandler works with FaviconDriver to fetch the specific type of
// favicon.
//
@@ -99,6 +105,10 @@ class FaviconHandler {
const std::vector<gfx::Size>& original_bitmap_sizes)>
ImageDownloadCallback;
+ typedef base::Callback<void(
+ const std::vector<favicon::FaviconURL>& favicons)>
+ ManifestDownloadCallback;
+
// Starts the download for the given favicon. When finished, the callback
// is called with the results. Returns the unique id of the download
// request, which will also be passed to the callback. In case of error, 0
@@ -111,6 +121,10 @@ class FaviconHandler {
int max_image_size,
ImageDownloadCallback callback) = 0;
+ // Downloads a WebManifest and returns the favicons listed there.
+ virtual void DownloadManifest(const GURL& url,
+ ManifestDownloadCallback callback) = 0;
+
// Returns whether the user is operating in an off-the-record context.
virtual bool IsOffTheRecord() = 0;
@@ -137,10 +151,15 @@ class FaviconHandler {
// Initiates loading the favicon for the specified url.
void FetchFavicon(const GURL& url);
- // Message Handler. Must be public, because also called from
- // PrerenderContents. Collects the |image_urls| list.
+ // Collects the candidate favicons as listed in the HTML head, as well as
+ // the WebManifest URL if available (or empty URL otherwise).
void OnUpdateCandidates(const GURL& page_url,
- const std::vector<favicon::FaviconURL>& candidates);
+ const std::vector<favicon::FaviconURL>& candidates,
+ const GURL& manifest_url);
+
+ // Returns the supported icon types, inferred from the handler type as passed
+ // in the constructor.
+ int icon_types() const { return icon_types_; }
// For testing.
const std::vector<GURL> GetIconURLs() const;
@@ -161,12 +180,6 @@ class FaviconHandler {
const favicon::FaviconURL& favicon_url,
const std::vector<int>& desired_pixel_sizes);
- friend bool operator==(const FaviconCandidate& lhs,
- const FaviconCandidate& rhs) {
- return lhs.icon_url == rhs.icon_url && lhs.icon_type == rhs.icon_type &&
- lhs.score == rhs.score;
- }
-
// Compare function used for std::stable_sort to sort in descending order.
static bool CompareScore(const FaviconCandidate& lhs,
const FaviconCandidate& rhs) {
@@ -187,6 +200,20 @@ class FaviconHandler {
static int GetIconTypesFromHandlerType(
FaviconDriverObserver::NotificationIconType handler_type);
+ // Called with the result of looking up cached icon data for the manifest's
+ // URL, which is used as icon URL.
+ void OnFaviconDataForManifestFromFaviconService(
+ const std::vector<favicon_base::FaviconRawBitmapResult>&
+ favicon_bitmap_results);
+
+ // Called when the dowloading of a manifest completes.
+ void OnDidDownloadManifest(const std::vector<FaviconURL>& candidates);
+
+ // Called when the actual list of favicon candidates to be processed is
+ // available, which can be either icon URLs listed in the HTML head instead
+ // or, if a Web Manifest was provided, the list of icons there.
+ void OnGotFinalIconURLCandidates(const std::vector<FaviconURL>& candidates);
+
// Called when the history request for favicon data mapped to |url_| has
// completed and the renderer has told us the icon URLs used by |url_|
void OnGotInitialHistoryDataAndIconURLCandidates();
@@ -201,6 +228,13 @@ class FaviconHandler {
// OnFaviconData() is called with the history data once it has been retrieved.
void DownloadCurrentCandidateOrAskFaviconService();
+ // Requests the favicon for |icon_url| from the favicon service. Unless in
+ // incognito, it also updates the page URL (url_) to |icon_url| mappings.
+ void GetFaviconAndUpdateMappingsUnlessIncognito(
+ const GURL& icon_url,
+ favicon_base::IconType icon_type,
+ const favicon_base::FaviconResultsCallback& callback);
+
// See description above class for details.
void OnFaviconData(const std::vector<favicon_base::FaviconRawBitmapResult>&
favicon_bitmap_results);
@@ -283,6 +317,10 @@ class FaviconHandler {
// |image_urls_| one by one.
bool redownload_icons_;
+ // Requests to the renderer to download a manifest.
+ base::CancelableCallback<Delegate::ManifestDownloadCallback::RunType>
+ manifest_download_request_;
+
// Requests to the renderer to download favicons.
base::CancelableCallback<Delegate::ImageDownloadCallback::RunType>
image_download_request_;
@@ -293,6 +331,14 @@ class FaviconHandler {
// Whether the largest icon should be downloaded.
const bool download_largest_icon_;
+ // The manifest URL from the renderer (or empty URL if none).
+ GURL manifest_url_;
+
+ // Original list of candidates provided to OnUpdateCandidates(), stored to
+ // be able to fall back to, in case a manifest was provided and downloading it
+ // failed (or provided no icons).
+ std::vector<FaviconURL> non_manifest_original_candidates_;
+
// The prioritized favicon candidates from the page back from the renderer.
std::vector<FaviconCandidate> candidates_;
« no previous file with comments | « components/favicon/core/favicon_driver_impl.cc ('k') | components/favicon/core/favicon_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698