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

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

Issue 10802066: Adds support for saving favicon size into history database. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Changes as requested by Sky and stevenjb 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 1da634c9af984ece421a93faed2c4120b41b3f9d..40e856789dddeadef9046e1006430fa1ed1efa80 100644
--- a/chrome/browser/favicon/favicon_handler.cc
+++ b/chrome/browser/favicon/favicon_handler.cc
@@ -282,7 +282,8 @@ void FaviconHandler::ProcessCurrentUrl() {
history_icon_.is_valid() &&
DoUrlAndIconMatch(
*current_candidate(),
- history_icon_.icon_url, history_icon_.icon_type)) {
+ history_icon_.elements[0].icon_url,
+ history_icon_.icon_type)) {
return;
}
@@ -398,35 +399,39 @@ bool FaviconHandler::ShouldSaveFavicon(const GURL& url) {
void FaviconHandler::OnFaviconDataForInitialURL(
FaviconService::Handle handle,
- history::FaviconData favicon) {
+ history::FaviconData favicon_data) {
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 &&
+ history::FaviconDataElement element;
+ if (!favicon_data.elements.empty())
+ element = favicon_data.elements[0];
+ 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))) {
+ *current_candidate(), element.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 = element.icon_url;
+ if (favicon_data.is_valid())
+ UpdateFavicon(entry, element.bitmap_data);
entry->GetFavicon().valid = true;
}
- if (favicon.known_icon && !favicon.expired) {
+ if (favicon_data.known_icon && !favicon_data.expired) {
+ history::FaviconDataElement element = favicon_data.elements[0];
if (current_candidate() &&
!DoUrlAndIconMatch(
- *current_candidate(), favicon.icon_url, favicon.icon_type)) {
+ *current_candidate(), element.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.
@@ -475,21 +480,22 @@ void FaviconHandler::DownloadFaviconOrAskHistory(
}
void FaviconHandler::OnFaviconData(FaviconService::Handle handle,
- history::FaviconData favicon) {
+ history::FaviconData favicon_data) {
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.is_valid()) {
// 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);
+ history::FaviconDataElement element = favicon_data.elements[0];
stevenjb 2012/08/15 22:59:18 Why do a copy here?
+ UpdateFavicon(entry, element.bitmap_data);
}
- 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,
@@ -497,9 +503,11 @@ 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 ||
+ favicon_data.elements.empty() || !(DoUrlAndIconMatch(
stevenjb 2012/08/15 22:59:18 nit: put !(DoUrlAndIconMatch( on a new line
+ *current_candidate(), favicon_data.elements[0].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,
@@ -507,7 +515,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