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..7a1a162b73f864c02e010b063d5df80c00fd84e9 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) { |
+ fetch_favicon_url_ = url; |
+ FaviconDriverImpl::FetchFavicon(url); |
+} |
+ |
void WebFaviconDriver::SaveFavicon() { |
NOTREACHED(); |
} |
@@ -73,7 +78,7 @@ GURL WebFaviconDriver::GetActiveURL() { |
} |
bool WebFaviconDriver::GetActiveFaviconValidity() { |
- return GetFaviconStatus().valid; |
+ return ActiveURLChangedSinceFetchFavicon() ? false : GetFaviconStatus().valid; |
sdefresne
2015/08/26 16:26:07
nit (optional): return !ActiveURLChangedSinceFetch
|
} |
void WebFaviconDriver::SetActiveFaviconValidity(bool validity) { |
@@ -81,7 +86,7 @@ void WebFaviconDriver::SetActiveFaviconValidity(bool validity) { |
} |
GURL WebFaviconDriver::GetActiveFaviconURL() { |
- return GetFaviconStatus().url; |
+ return ActiveURLChangedSinceFetchFavicon() ? GURL() : GetFaviconStatus().url; |
} |
void WebFaviconDriver::SetActiveFaviconURL(const GURL& url) { |
@@ -92,8 +97,22 @@ void WebFaviconDriver::SetActiveFaviconImage(const gfx::Image& image) { |
GetFaviconStatus().image = image; |
} |
+bool WebFaviconDriver::ShouldSendFaviconAvailableNotifications() { |
+ // FaviconHandler sends notifications with the assumption that the active URL |
+ // has not changed. Suppress FaviconHandler notifications if the active URL |
+ // has changed. |
+ return !ActiveURLChangedSinceFetchFavicon(); |
+} |
+ |
+bool WebFaviconDriver::ActiveURLChangedSinceFetchFavicon() { |
+ // 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(). |
+ return GetActiveURL() != fetch_favicon_url_; |
+} |
+ |
web::FaviconStatus& WebFaviconDriver::GetFaviconStatus() { |
- DCHECK(web_state()->GetNavigationManager()->GetVisibleItem()); |
+ DCHECK(!ActiveURLChangedSinceFetchFavicon()); |
return web_state()->GetNavigationManager()->GetVisibleItem()->GetFavicon(); |
} |
@@ -110,6 +129,9 @@ WebFaviconDriver::~WebFaviconDriver() { |
void WebFaviconDriver::FaviconUrlUpdated( |
const std::vector<web::FaviconURL>& candidates) { |
+ if (fetch_favicon_url_.is_empty() || ActiveURLChangedSinceFetchFavicon()) |
+ return; |
+ |
DCHECK(!candidates.empty()); |
OnUpdateFaviconURL(FaviconURLsFromWebFaviconURLs(candidates)); |
} |