Index: components/favicon/ios/web_favicon_driver.cc |
diff --git a/components/favicon/ios/web_favicon_driver.cc b/components/favicon/ios/web_favicon_driver.cc |
index b1a8e11a635c0ab8110aaff18fcff38edf412775..a3557bcfbf0df3a09f0b7aa49d41e9491fe365c3 100644 |
--- a/components/favicon/ios/web_favicon_driver.cc |
+++ b/components/favicon/ios/web_favicon_driver.cc |
@@ -43,6 +43,12 @@ gfx::Image WebFaviconDriver::GetFavicon() const { |
return item ? item->GetFavicon().image : gfx::Image(); |
} |
+GURL WebFaviconDriver::GetFaviconURL() const { |
+ web::NavigationItem* item = |
+ web_state()->GetNavigationManager()->GetLastCommittedItem(); |
+ return item ? item->GetFavicon().url : GURL(); |
+} |
+ |
bool WebFaviconDriver::FaviconIsValid() const { |
web::NavigationItem* item = |
web_state()->GetNavigationManager()->GetLastCommittedItem(); |
@@ -72,25 +78,23 @@ GURL WebFaviconDriver::GetActiveURL() { |
return item ? item->GetURL() : GURL(); |
} |
-void WebFaviconDriver::SetActiveFaviconValidity(bool validity) { |
- GetFaviconStatus().valid = validity; |
-} |
- |
-GURL WebFaviconDriver::GetActiveFaviconURL() { |
- return GetFaviconStatus().url; |
-} |
- |
-void WebFaviconDriver::SetActiveFaviconURL(const GURL& url) { |
- GetFaviconStatus().url = url; |
-} |
- |
-void WebFaviconDriver::SetActiveFaviconImage(const gfx::Image& image) { |
- GetFaviconStatus().image = image; |
-} |
+void WebFaviconDriver::OnFaviconUpdated( |
+ const GURL& page_url, |
+ FaviconDriverObserver::NotificationIconType notification_icon_type, |
+ const GURL& icon_url, |
+ bool icon_url_changed, |
+ const gfx::Image& image) { |
+ // Check whether the active URL has changed since FetchFavicon() was called. |
+ // On iOS, the active URL can change between calls to FetchFavicon(). For |
+ // instance, FetchFavicon() is not synchronously called when the active URL |
+ // changes as a result of CRWSessionController::goToEntry(). |
+ web::NavigationItem* item = |
+ web_state()->GetNavigationManager()->GetVisibleItem(); |
+ if (!item || item->GetURL() != page_url) |
+ return; |
-web::FaviconStatus& WebFaviconDriver::GetFaviconStatus() { |
- DCHECK(web_state()->GetNavigationManager()->GetVisibleItem()); |
- return web_state()->GetNavigationManager()->GetVisibleItem()->GetFavicon(); |
+ NotifyFaviconUpdatedObservers(notification_icon_type, icon_url, |
+ icon_url_changed, image); |
} |
WebFaviconDriver::WebFaviconDriver(web::WebState* web_state, |