Chromium Code Reviews| Index: chrome/browser/fav_icon_helper.cc |
| diff --git a/chrome/browser/fav_icon_helper.cc b/chrome/browser/fav_icon_helper.cc |
| index a40ec2a7ffbcdc970dc8ab50721ba0abb2ee66ef..a7fbd5cababc8b380b84bbb8bd289d6abdd29825 100644 |
| --- a/chrome/browser/fav_icon_helper.cc |
| +++ b/chrome/browser/fav_icon_helper.cc |
| @@ -52,7 +52,8 @@ void FavIconHelper::FetchFavIcon(const GURL& url) { |
| // renderer is going to notify us (well TabContents) when the favicon url is |
| // available. |
| if (GetFaviconService()) { |
| - GetFaviconService()->GetFaviconForURL(url_, &cancelable_consumer_, |
| + GetFaviconService()->GetFaviconForURL(url_, history::FAV_ICON, |
| + &cancelable_consumer_, |
| NewCallback(this, &FavIconHelper::OnFavIconDataForInitialURL)); |
| } |
| } |
| @@ -83,7 +84,8 @@ void FavIconHelper::SetFavIcon( |
| if (GetFaviconService() && ShouldSaveFavicon(url)) { |
| std::vector<unsigned char> image_data; |
| gfx::PNGCodec::EncodeBGRASkBitmap(sized_image, false, &image_data); |
| - GetFaviconService()->SetFavicon(url, image_url, image_data); |
| + GetFaviconService()->SetFavicon(url, image_url, image_data, |
| + history::FAV_ICON); |
| } |
| if (url == url_) { |
| @@ -182,32 +184,29 @@ NavigationEntry* FavIconHelper::GetEntry() { |
| void FavIconHelper::OnFavIconDataForInitialURL( |
| FaviconService::Handle handle, |
| - bool know_favicon, |
| - scoped_refptr<RefCountedMemory> data, |
| - bool expired, |
| - GURL icon_url) { |
| + history::FaviconData favicon) { |
| NavigationEntry* entry = GetEntry(); |
| if (!entry) |
| return; |
| got_fav_icon_from_history_ = true; |
| - fav_icon_expired_ = (know_favicon && expired); |
| + fav_icon_expired_ = (favicon.known_icon && favicon.expired); |
| - if (know_favicon && !entry->favicon().is_valid() && |
| - (!got_fav_icon_url_ || entry->favicon().url() == icon_url)) { |
| + if (favicon.known_icon && !entry->favicon().is_valid() && |
| + (!got_fav_icon_url_ || entry->favicon().url() == favicon.icon_url)) { |
| // 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->favicon().set_url(icon_url); |
| - if (data.get() && data->size()) |
| - UpdateFavIcon(entry, data); |
| + entry->favicon().set_url(favicon.icon_url); |
| + if (favicon.image_data.get() && favicon.image_data->size()) |
|
sky
2011/03/11 17:56:45
is_valid
|
| + UpdateFavIcon(entry, favicon.image_data); |
| entry->favicon().set_is_valid(true); |
| } |
| - if (know_favicon && !expired) { |
| - if (got_fav_icon_url_ && entry->favicon().url() != icon_url) { |
| + if (favicon.known_icon && !favicon.expired) { |
| + if (got_fav_icon_url_ && entry->favicon().url() != favicon.icon_url) { |
| // 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. |
| @@ -235,6 +234,7 @@ void FavIconHelper::DownloadFavIconOrAskHistory(NavigationEntry* entry) { |
| if (profile()->IsOffTheRecord()) { |
| GetFaviconService()->GetFavicon( |
| entry->favicon().url(), |
| + history::FAV_ICON, |
| &cancelable_consumer_, |
| NewCallback(this, &FavIconHelper::OnFavIconData)); |
| } else { |
| @@ -246,7 +246,9 @@ void FavIconHelper::DownloadFavIconOrAskHistory(NavigationEntry* entry) { |
| // Issue the request and associate the current page ID with it. |
| GetFaviconService()->UpdateFaviconMappingAndFetch( |
| entry->url(), |
| - entry->favicon().url(), &cancelable_consumer_, |
| + entry->favicon().url(), |
| + history::FAV_ICON, |
| + &cancelable_consumer_, |
| NewCallback(this, &FavIconHelper::OnFavIconData)); |
| } |
| } |
| @@ -254,10 +256,7 @@ void FavIconHelper::DownloadFavIconOrAskHistory(NavigationEntry* entry) { |
| void FavIconHelper::OnFavIconData( |
| FaviconService::Handle handle, |
| - bool know_favicon, |
| - scoped_refptr<RefCountedMemory> data, |
| - bool expired, |
| - GURL icon_url) { |
| + history::FaviconData favicon) { |
| NavigationEntry* entry = GetEntry(); |
| if (!entry) |
| return; |
| @@ -265,14 +264,14 @@ void FavIconHelper::OnFavIconData( |
| // No need to update the favicon url. By the time we get here |
| // UpdateFavIconURL will have set the favicon url. |
| - if (know_favicon && data.get() && data->size()) { |
| + if (favicon.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, data); |
| + UpdateFavIcon(entry, favicon.image_data); |
| } |
| - if (!know_favicon || expired) { |
| + if (!favicon.known_icon || favicon.expired) { |
| // We don't know the favicon, or it is out of date. Request the current one. |
| ScheduleDownload(entry->url(), entry->favicon().url(), kFavIconSize, NULL); |
| } |