Index: components/favicon/core/favicon_handler.h |
diff --git a/components/favicon/core/favicon_handler.h b/components/favicon/core/favicon_handler.h |
index 9e6e22b9f97126bc1762aa49db194d4225a8f635..e2a904b11e146b4811cef386955957c7f6cef04e 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" |
@@ -86,6 +87,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 |
@@ -98,6 +103,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; |
@@ -124,10 +133,11 @@ 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. |
- void OnUpdateFaviconURL(const GURL& page_url, |
- const std::vector<favicon::FaviconURL>& candidates); |
+ // 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 base::Optional<GURL>& manifest_url); |
// For testing. |
const std::vector<GURL> GetIconURLs() const; |
@@ -174,6 +184,11 @@ class FaviconHandler { |
static int GetIconTypesFromHandlerType( |
FaviconDriverObserver::NotificationIconType handler_type); |
+ // Called a 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(); |
@@ -182,6 +197,10 @@ class FaviconHandler { |
void OnFaviconDataForInitialURLFromFaviconService(const std::vector< |
favicon_base::FaviconRawBitmapResult>& favicon_bitmap_results); |
+ void OnFaviconDataForManifestURLFromFaviconService( |
+ const std::vector<favicon_base::FaviconRawBitmapResult>& |
+ favicon_bitmap_results); |
+ |
// If the favicon currently mapped to |url_| has expired, downloads the |
// current candidate favicon from the renderer. Otherwise requests data for |
// the current favicon from history. If data is requested from history, |
@@ -265,9 +284,13 @@ 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> |
- download_request_; |
+ image_download_request_; |
// The combination of the supported icon types. |
const int icon_types_; |
@@ -275,6 +298,9 @@ 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_; |
+ |
// The prioritized favicon candidates from the page back from the renderer. |
std::vector<FaviconCandidate> candidates_; |