Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Unified Diff: components/favicon/ios/web_favicon_driver.cc

Issue 1407353012: Refactor FaviconDriver::OnFaviconAvailable() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@initial_simplify
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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,
« components/favicon/core/favicon_handler.cc ('K') | « components/favicon/ios/web_favicon_driver.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698