summaryrefslogtreecommitdiffstats
path: root/chrome/browser/fav_icon_helper.cc
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-08 16:24:33 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-08 16:24:33 +0000
commitbf5c2ff3931c43b98095d33f8bc1b98379afe16f (patch)
tree7c87f5a7f693ac8b5a43cf5f2eebe0ac462b1853 /chrome/browser/fav_icon_helper.cc
parente9d7b6cf453475ad269785f3775700339c8a03fb (diff)
downloadchromium_src-bf5c2ff3931c43b98095d33f8bc1b98379afe16f.zip
chromium_src-bf5c2ff3931c43b98095d33f8bc1b98379afe16f.tar.gz
chromium_src-bf5c2ff3931c43b98095d33f8bc1b98379afe16f.tar.bz2
Split out some of the RVHDelegate functions into separate sub-classes. To limit
the scope, this patch just contains those delegate functions implemented only by TabContents, plus the favicon functions implemented by the FavIconHelper. The only changes are re-ordering and moving the functions, and changes in the way that the functions are called through the new optional delegate. Review URL: http://codereview.chromium.org/149239 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20152 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/fav_icon_helper.cc')
-rw-r--r--chrome/browser/fav_icon_helper.cc66
1 files changed, 39 insertions, 27 deletions
diff --git a/chrome/browser/fav_icon_helper.cc b/chrome/browser/fav_icon_helper.cc
index 62a26cd..564c262 100644
--- a/chrome/browser/fav_icon_helper.cc
+++ b/chrome/browser/fav_icon_helper.cc
@@ -40,28 +40,6 @@ void FavIconHelper::FetchFavIcon(const GURL& url) {
}
}
-void FavIconHelper::SetFavIconURL(const GURL& icon_url) {
- NavigationEntry* entry = GetEntry();
- if (!entry)
- return;
-
- got_fav_icon_url_ = true;
-
- if (!GetHistoryService())
- return;
-
- if (!fav_icon_expired_ && entry->favicon().is_valid() &&
- entry->favicon().url() == icon_url) {
- // We already have the icon, no need to proceed.
- return;
- }
-
- entry->favicon().set_url(icon_url);
-
- if (got_fav_icon_from_history_)
- DownloadFavIconOrAskHistory(entry);
-}
-
Profile* FavIconHelper::profile() {
return tab_contents_->profile();
}
@@ -126,6 +104,41 @@ void FavIconHelper::UpdateFavIcon(NavigationEntry* entry,
tab_contents_->NotifyNavigationStateChanged(TabContents::INVALIDATE_TAB);
}
+void FavIconHelper::UpdateFavIconURL(RenderViewHost* render_view_host,
+ int32 page_id,
+ const GURL& icon_url) {
+ NavigationEntry* entry = GetEntry();
+ if (!entry)
+ return;
+
+ got_fav_icon_url_ = true;
+
+ if (!GetHistoryService())
+ return;
+
+ if (!fav_icon_expired_ && entry->favicon().is_valid() &&
+ entry->favicon().url() == icon_url) {
+ // We already have the icon, no need to proceed.
+ return;
+ }
+
+ entry->favicon().set_url(icon_url);
+
+ if (got_fav_icon_from_history_)
+ DownloadFavIconOrAskHistory(entry);
+}
+
+void FavIconHelper::DidDownloadFavIcon(RenderViewHost* render_view_host,
+ int id,
+ const GURL& image_url,
+ bool errored,
+ const SkBitmap& image) {
+ if (errored)
+ FavIconDownloadFailed(id);
+ else
+ SetFavIcon(id, image_url, image);
+}
+
NavigationEntry* FavIconHelper::GetEntry() {
NavigationEntry* entry = tab_contents_->controller().GetActiveEntry();
if (entry && entry->url() == url_ &&
@@ -235,12 +248,11 @@ void FavIconHelper::OnFavIconData(
}
void FavIconHelper::ScheduleDownload(NavigationEntry* entry) {
- const int download_id = tab_contents_->render_view_host()->DownloadImage(
+ const int download_id = tab_contents_->render_view_host()->DownloadFavIcon(
entry->favicon().url(), kFavIconSize);
- if (!download_id) {
- // Download request failed.
- return;
- }
+ if (!download_id)
+ return; // Download request failed.
+
// Download ids should be unique.
DCHECK(download_requests_.find(download_id) == download_requests_.end());
download_requests_[download_id] =