Index: components/favicon/content/content_favicon_driver.cc |
diff --git a/components/favicon/content/content_favicon_driver.cc b/components/favicon/content/content_favicon_driver.cc |
index 8cf90669a7e1b6b01a7eb4195e86da9227e9e31f..7c8c34f7445ae99fd9d5341a594461ba5646c89e 100644 |
--- a/components/favicon/content/content_favicon_driver.cc |
+++ b/components/favicon/content/content_favicon_driver.cc |
@@ -73,6 +73,19 @@ gfx::Image ContentFaviconDriver::GetFavicon() const { |
return gfx::Image(); |
} |
+GURL ContentFaviconDriver::GetFaviconURL() const { |
+ const content::NavigationController& controller = |
+ web_contents()->GetController(); |
+ content::NavigationEntry* entry = controller.GetTransientEntry(); |
+ if (entry) |
+ return entry->GetFavicon().url; |
+ |
+ entry = controller.GetLastCommittedEntry(); |
+ if (entry) |
+ return entry->GetFavicon().url; |
+ return GURL(); |
+} |
+ |
bool ContentFaviconDriver::FaviconIsValid() const { |
const content::NavigationController& controller = |
web_contents()->GetController(); |
@@ -113,27 +126,6 @@ GURL ContentFaviconDriver::GetActiveURL() { |
return entry ? entry->GetURL() : GURL(); |
} |
-void ContentFaviconDriver::SetActiveFaviconValidity(bool valid) { |
- GetFaviconStatus().valid = valid; |
-} |
- |
-GURL ContentFaviconDriver::GetActiveFaviconURL() { |
- return GetFaviconStatus().url; |
-} |
- |
-void ContentFaviconDriver::SetActiveFaviconURL(const GURL& url) { |
- GetFaviconStatus().url = url; |
-} |
- |
-void ContentFaviconDriver::SetActiveFaviconImage(const gfx::Image& image) { |
- GetFaviconStatus().image = image; |
-} |
- |
-content::FaviconStatus& ContentFaviconDriver::GetFaviconStatus() { |
- DCHECK(web_contents()->GetController().GetLastCommittedEntry()); |
- return web_contents()->GetController().GetLastCommittedEntry()->GetFavicon(); |
-} |
- |
ContentFaviconDriver::ContentFaviconDriver( |
content::WebContents* web_contents, |
FaviconService* favicon_service, |
@@ -146,9 +138,28 @@ ContentFaviconDriver::ContentFaviconDriver( |
ContentFaviconDriver::~ContentFaviconDriver() { |
} |
-void ContentFaviconDriver::NotifyFaviconUpdated(bool icon_url_changed) { |
- FaviconDriverImpl::NotifyFaviconUpdated(icon_url_changed); |
- web_contents()->NotifyNavigationStateChanged(content::INVALIDATE_TYPE_TAB); |
+void ContentFaviconDriver::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. |
+ // This should never occur. |
sky
2015/11/20 00:44:26
DCHECK
pkotwicz
2015/11/21 23:04:08
Done.
|
+ content::NavigationEntry* entry = |
+ web_contents()->GetController().GetLastCommittedEntry(); |
+ if (!entry || entry->GetURL() != page_url) |
+ return; |
+ |
+ if (notification_icon_type == FaviconDriverObserver::NON_TOUCH_16_DIP) { |
+ entry->GetFavicon().valid = true; |
+ entry->GetFavicon().url = icon_url; |
+ entry->GetFavicon().image = image; |
+ web_contents()->NotifyNavigationStateChanged(content::INVALIDATE_TYPE_TAB); |
+ } |
+ |
+ NotifyFaviconUpdatedObservers(notification_icon_type, icon_url, |
+ icon_url_changed, image); |
} |
void ContentFaviconDriver::DidUpdateFaviconURL( |