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 b83fb790824f0925cd2e549710f071545b2838d8..27b942da86fc468417bae20de9e80c38dc5a6aba 100644 |
--- a/components/favicon/ios/web_favicon_driver.cc |
+++ b/components/favicon/ios/web_favicon_driver.cc |
@@ -33,6 +33,11 @@ void WebFaviconDriver::CreateForWebState( |
history_service, bookmark_model)); |
} |
+void WebFaviconDriver::FetchFavicon(const GURL& url) override { |
+ fetch_favicon_url_ = url; |
+ FaviconDriverImpl::FetchFavicon(url); |
+} |
+ |
void WebFaviconDriver::SaveFavicon() { |
NOTREACHED(); |
} |
@@ -92,9 +97,20 @@ void WebFaviconDriver::SetActiveFaviconImage(const gfx::Image& image) { |
GetFaviconStatus().image = image; |
} |
+bool WebFaviconDriver::ShouldSendFaviconAvailableNotifications() override { |
+ // On iOS the active URL can change in between calls to FetchFavicon(). For |
+ // instance, FetchFavicon() is not synchronously called when the active URL |
+ // changes as a result of CRWSessionController::goToEntry(). FaviconHandler |
pkotwicz
2015/08/23 19:59:47
FetchFavicon() is called by CRWUIWebViewWebControl
|
+ // sends notifications with the assumption that the active URL has not |
+ // changed. Suppress FaviconHandler notifications if the active URL has |
+ // changed. |
+ return GetActiveURL() == fetch_favicon_url_; |
+} |
+ |
web::FaviconStatus& WebFaviconDriver::GetFaviconStatus() { |
- DCHECK(web_state()->GetNavigationManager()->GetVisibleItem()); |
- return web_state()->GetNavigationManager()->GetVisibleItem()->GetFavicon(); |
+ web::NavigationItem* item = |
+ web_state()->GetNavigationManager()->GetVisibleItem(); |
+ return item ? item->GetFavicon() : web::FaviconStatus(); |
} |
WebFaviconDriver::WebFaviconDriver(web::WebState* web_state, |