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

Unified Diff: chrome/browser/favicon/favicon_handler.cc

Issue 10968026: Use the default favicon in place of stale favicons. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/favicon/favicon_handler.cc
diff --git a/chrome/browser/favicon/favicon_handler.cc b/chrome/browser/favicon/favicon_handler.cc
index 11e0d62d960158d6c7a633a46cd2fe4954437966..ed91dcc3285c1a0fc9f2cc80d845394d761e5ab8 100644
--- a/chrome/browser/favicon/favicon_handler.cc
+++ b/chrome/browser/favicon/favicon_handler.cc
@@ -21,7 +21,9 @@
#include "chrome/common/icon_messages.h"
#include "content/public/browser/favicon_status.h"
#include "content/public/browser/navigation_entry.h"
+#include "grit/ui_resources.h"
#include "skia/ext/image_operations.h"
+#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/codec/png_codec.h"
#include "ui/gfx/image/image.h"
#include "ui/gfx/image/image_skia.h"
@@ -370,7 +372,12 @@ void FaviconHandler::ProcessCurrentUrl() {
history::FAVICON))
return;
+ // TODO(msw): valid depending on url, or leave as-is?
+ entry->GetFavicon().valid = false;
entry->GetFavicon().url = current_candidate()->icon_url;
+ // TODO(msw): Will this cause flicker? Do this when the fetch errors out?
+ ResourceBundle& rb = ResourceBundle::GetSharedInstance();
+ entry->GetFavicon().image = rb.GetNativeImageNamed(IDR_DEFAULT_FAVICON);
} else if (!favicon_expired_or_incomplete_ && got_favicon_from_history_ &&
HasValidResult(history_results_) &&
DoUrlsAndIconsMatch(*current_candidate(), history_results_)) {
@@ -428,7 +435,15 @@ void FaviconHandler::OnDidDownloadFavicon(
// Remove the first member of image_urls_ and process the remaining.
image_urls_.pop_front();
ProcessCurrentUrl();
- } else if (favicon_candidate_.icon_type != history::INVALID_ICON) {
+ } else {
+ // Show the default favicon if the response was invalid.
+ if (favicon_candidate_.icon_type != history::INVALID_ICON) {
+ ResourceBundle& rb = ResourceBundle::GetSharedInstance();
+ favicon_candidate_.image = rb.GetNativeImageNamed(IDR_DEFAULT_FAVICON);
+ // TODO(msw): the icon_type is not necessarily |FAVICON|...
+ favicon_candidate_.icon_type = history::FAVICON;
+ }
+
// No more icons to request, set the favicon from the candidate.
SetFavicon(favicon_candidate_.url,
favicon_candidate_.image_url,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698