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

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

Issue 10870022: Change FaviconData to be able to return data for multiple bitmaps for same icon URL (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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: chrome/browser/favicon/favicon_handler.cc
diff --git a/chrome/browser/favicon/favicon_handler.cc b/chrome/browser/favicon/favicon_handler.cc
index d33e808e645ff635889ab6325c073d7d78b1d4c0..df458ad21fa60cbc29d0f77297d7d35d5692ba17 100644
--- a/chrome/browser/favicon/favicon_handler.cc
+++ b/chrome/browser/favicon/favicon_handler.cc
@@ -276,7 +276,7 @@ void FaviconHandler::ProcessCurrentUrl() {
entry->GetFavicon().url = current_candidate()->icon_url;
} else if (!favicon_expired_ && got_favicon_from_history_ &&
- history_icon_.is_valid() &&
+ history_icon_.has_valid_bitmaps() &&
DoUrlAndIconMatch(
*current_candidate(),
history_icon_.icon_url, history_icon_.icon_type)) {
@@ -396,35 +396,36 @@ bool FaviconHandler::ShouldSaveFavicon(const GURL& url) {
void FaviconHandler::OnFaviconDataForInitialURL(
FaviconService::Handle handle,
- history::FaviconData favicon) {
+ history::FaviconData favicon_data,
+ std::vector<GURL> icon_urls_in_db) {
NavigationEntry* entry = GetEntry();
if (!entry)
return;
got_favicon_from_history_ = true;
- history_icon_ = favicon;
+ history_icon_ = favicon_data;
- favicon_expired_ = (favicon.known_icon && favicon.expired);
+ favicon_expired_ = (favicon_data.known_icon && favicon_data.expired());
- if (favicon.known_icon && favicon.icon_type == history::FAVICON &&
+ if (favicon_data.known_icon && favicon_data.icon_type == history::FAVICON &&
!entry->GetFavicon().valid &&
(!current_candidate() ||
- DoUrlAndIconMatch(
- *current_candidate(), favicon.icon_url, favicon.icon_type))) {
+ DoUrlAndIconMatch(*current_candidate(),
+ favicon_data.icon_url, favicon_data.icon_type))) {
// The db knows the favicon (although it may be out of date) and the entry
// doesn't have an icon. Set the favicon now, and if the favicon turns out
// to be expired (or the wrong url) we'll fetch later on. This way the
// user doesn't see a flash of the default favicon.
- entry->GetFavicon().url = favicon.icon_url;
- if (favicon.is_valid())
- UpdateFavicon(entry, favicon.image_data);
+ entry->GetFavicon().url = favicon_data.icon_url;
+ if (favicon_data.has_valid_bitmaps())
+ UpdateFavicon(entry, favicon_data.first_bitmap());
entry->GetFavicon().valid = true;
}
- if (favicon.known_icon && !favicon.expired) {
+ if (favicon_data.known_icon && !favicon_data.expired()) {
if (current_candidate() &&
- !DoUrlAndIconMatch(
- *current_candidate(), favicon.icon_url, favicon.icon_type)) {
+ !DoUrlAndIconMatch(*current_candidate(),
+ favicon_data.icon_url, favicon_data.icon_type)) {
// Mapping in the database is wrong. DownloadFavIconOrAskHistory will
// update the mapping for this url and download the favicon if we don't
// already have it.
@@ -473,21 +474,22 @@ void FaviconHandler::DownloadFaviconOrAskHistory(
}
void FaviconHandler::OnFaviconData(FaviconService::Handle handle,
- history::FaviconData favicon) {
+ history::FaviconData favicon_data,
+ std::vector<GURL> icon_urls_in_db) {
NavigationEntry* entry = GetEntry();
if (!entry)
return;
// No need to update the favicon url. By the time we get here
// UpdateFaviconURL will have set the favicon url.
- if (favicon.icon_type == history::FAVICON) {
- if (favicon.is_valid()) {
+ if (favicon_data.icon_type == history::FAVICON) {
+ if (favicon_data.has_valid_bitmaps()) {
// There is a favicon, set it now. If expired we'll download the current
// one again, but at least the user will get some icon instead of the
// default and most likely the current one is fine anyway.
- UpdateFavicon(entry, favicon.image_data);
+ UpdateFavicon(entry, favicon_data.first_bitmap());
}
- if (!favicon.known_icon || favicon.expired) {
+ if (!favicon_data.known_icon || favicon_data.expired()) {
// We don't know the favicon, or it is out of date. Request the current
// one.
ScheduleDownload(entry->GetURL(), entry->GetFavicon().url,
@@ -495,9 +497,10 @@ void FaviconHandler::OnFaviconData(FaviconService::Handle handle,
history::FAVICON,
FaviconTabHelper::ImageDownloadCallback());
}
- } else if (current_candidate() && (!favicon.known_icon || favicon.expired ||
- !(DoUrlAndIconMatch(
- *current_candidate(), favicon.icon_url, favicon.icon_type)))) {
+ } else if (current_candidate() &&
+ (!favicon_data.known_icon || favicon_data.expired() ||
+ !(DoUrlAndIconMatch(*current_candidate(),
+ favicon_data.icon_url, favicon_data.icon_type)))) {
// We don't know the favicon, it is out of date or its type is not same as
// one got from page. Request the current one.
ScheduleDownload(entry->GetURL(), current_candidate()->icon_url,
@@ -505,7 +508,7 @@ void FaviconHandler::OnFaviconData(FaviconService::Handle handle,
ToHistoryIconType(current_candidate()->icon_type),
FaviconTabHelper::ImageDownloadCallback());
}
- history_icon_ = favicon;
+ history_icon_ = favicon_data;
}
int FaviconHandler::ScheduleDownload(

Powered by Google App Engine
This is Rietveld 408576698