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

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

Issue 1079523005: Fix FaviconHandler when it has multiple icon URLs and one of them is invalid (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@fix_favicon3
Patch Set: Created 5 years, 8 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 | « no previous file | components/favicon/core/favicon_handler_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/favicon/core/favicon_handler.cc
diff --git a/components/favicon/core/favicon_handler.cc b/components/favicon/core/favicon_handler.cc
index 1d5eac7ccdf34289398f1c2aa256434a160ccb5a..7bfe2cf33a87d6a8b0c9963ace8630a235fa2503 100644
--- a/components/favicon/core/favicon_handler.cc
+++ b/components/favicon/core/favicon_handler.cc
@@ -439,13 +439,15 @@ void FaviconHandler::OnDidDownloadFavicon(
// Remove the first member of image_urls_ and process the remaining.
image_urls_.erase(image_urls_.begin());
ProcessCurrentUrl();
- } else if (best_favicon_candidate_.icon_type != favicon_base::INVALID_ICON) {
- // No more icons to request, set the favicon from the candidate.
- SetFavicon(best_favicon_candidate_.url,
- best_favicon_candidate_.image_url,
- best_favicon_candidate_.image,
- best_favicon_candidate_.icon_type);
- // Reset candidate.
+ } else {
+ // We have either found the ideal candidate or run out of candidates.
+ if (best_favicon_candidate_.icon_type != favicon_base::INVALID_ICON) {
+ // No more icons to request, set the favicon from the candidate.
+ SetFavicon(best_favicon_candidate_.url, best_favicon_candidate_.image_url,
+ best_favicon_candidate_.image,
+ best_favicon_candidate_.icon_type);
+ }
+ // Clear download related state.
image_urls_.clear();
download_requests_.clear();
best_favicon_candidate_ = FaviconCandidate();
@@ -682,11 +684,18 @@ void FaviconHandler::ScheduleDownload(const GURL& url,
// for more details about the max bitmap size.
const int download_id = DownloadFavicon(image_url,
GetMaximalIconSize(icon_type));
- if (download_id) {
- // Download ids should be unique.
- DCHECK(download_requests_.find(download_id) == download_requests_.end());
- download_requests_[download_id] =
- DownloadRequest(url, image_url, icon_type);
+
+ // Download ids should be unique.
+ DCHECK(download_requests_.find(download_id) == download_requests_.end());
+ download_requests_[download_id] = DownloadRequest(url, image_url, icon_type);
+
+ if (download_id == 0) {
+ // If DownloadFavicon() did not start a download, it returns a download id
+ // of 0. We still need to call OnDidDownloadFavicon() because the method is
+ // responsible for initiating the data request for the next candidate.
+ OnDidDownloadFavicon(download_id, image_url, std::vector<SkBitmap>(),
+ std::vector<gfx::Size>());
+
}
}
« no previous file with comments | « no previous file | components/favicon/core/favicon_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698