Index: chrome/browser/favicon/favicon_tab_helper.cc |
diff --git a/chrome/browser/favicon/favicon_tab_helper.cc b/chrome/browser/favicon/favicon_tab_helper.cc |
index 3992f8f02aca60b86bc066008245594ad18c5a90..62350b32461b437ed92ac8d467f133c2d6f73c74 100644 |
--- a/chrome/browser/favicon/favicon_tab_helper.cc |
+++ b/chrome/browser/favicon/favicon_tab_helper.cc |
@@ -136,6 +136,14 @@ void FaviconTabHelper::SaveFavicon() { |
entry->GetURL(), favicon.url, favicon_base::FAVICON, favicon.image); |
} |
+void FaviconTabHelper::AddObserver(Observer* observer) { |
+ observer_list_.AddObserver(observer); |
+} |
+ |
+void FaviconTabHelper::RemoveObserver(Observer* observer) { |
+ observer_list_.RemoveObserver(observer); |
+} |
+ |
int FaviconTabHelper::StartDownload(const GURL& url, int max_image_size) { |
FaviconService* favicon_service = FaviconServiceFactory::GetForProfile( |
profile_->GetOriginalProfile(), Profile::IMPLICIT_ACCESS); |
@@ -151,14 +159,6 @@ int FaviconTabHelper::StartDownload(const GURL& url, int max_image_size) { |
base::Bind(&FaviconTabHelper::DidDownloadFavicon,base::Unretained(this))); |
} |
-void FaviconTabHelper::NotifyFaviconUpdated(bool icon_url_changed) { |
- content::NotificationService::current()->Notify( |
- chrome::NOTIFICATION_FAVICON_UPDATED, |
- content::Source<WebContents>(web_contents()), |
- content::Details<bool>(&icon_url_changed)); |
- web_contents()->NotifyNavigationStateChanged(content::INVALIDATE_TYPE_TAB); |
-} |
- |
bool FaviconTabHelper::IsOffTheRecord() { |
DCHECK(web_contents()); |
return web_contents()->GetBrowserContext()->IsOffTheRecord(); |
@@ -195,6 +195,29 @@ void FaviconTabHelper::SetActiveFaviconValidity(bool validity) { |
GetFaviconStatus().valid = validity; |
} |
+void FaviconTabHelper::OnFaviconAvailable(const gfx::Image& image, |
+ const GURL& icon_url, |
+ bool update_active_favicon) { |
+ if (update_active_favicon) { |
+ // No matter what happens, we need to mark the favicon as being set. |
+ SetActiveFaviconValidity(true); |
+ bool icon_url_changed = GetActiveFaviconURL() != icon_url; |
+ SetActiveFaviconURL(icon_url); |
+ |
+ if (image.IsEmpty()) |
+ return; |
+ |
+ SetActiveFaviconImage(image); |
+ content::NotificationService::current()->Notify( |
+ chrome::NOTIFICATION_FAVICON_UPDATED, |
+ content::Source<WebContents>(web_contents()), |
+ content::Details<bool>(&icon_url_changed)); |
+ web_contents()->NotifyNavigationStateChanged(content::INVALIDATE_TYPE_TAB); |
+ } |
+ if (!image.IsEmpty()) |
+ FOR_EACH_OBSERVER(Observer, observer_list_, OnFaviconAvailable(image)); |
+} |
+ |
content::FaviconStatus& FaviconTabHelper::GetFaviconStatus() { |
DCHECK(web_contents()->GetController().GetActiveEntry()); |
return web_contents()->GetController().GetActiveEntry()->GetFavicon(); |