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

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

Issue 2799273002: Add support to process favicons from Web Manifests (Closed)
Patch Set: Reverted fieldtrial_testing_config.json 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
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..82787e914a28611078a4f4e377e01a9112db9da9 100644
--- a/components/favicon/core/favicon_handler.h
+++ b/components/favicon/core/favicon_handler.h
@@ -13,6 +13,7 @@
#include "base/cancelable_callback.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
+#include "base/optional.h"
#include "base/task/cancelable_task_tracker.h"
#include "components/favicon/core/favicon_driver_observer.h"
#include "components/favicon/core/favicon_url.h"
@@ -23,10 +24,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 +106,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 +122,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 +152,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.
void OnUpdateCandidates(const GURL& page_url,
- const std::vector<favicon::FaviconURL>& candidates);
+ const std::vector<favicon::FaviconURL>& candidates,
+ const base::Optional<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;
@@ -187,6 +207,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 +235,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 +324,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 +338,14 @@ class FaviconHandler {
// Whether the largest icon should be downloaded.
const bool download_largest_icon_;
+ // The manifest URL from the renderer.
+ base::Optional<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_;

Powered by Google App Engine
This is Rietveld 408576698