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

Side by Side Diff: components/favicon/ios/web_favicon_driver.cc

Issue 1399913002: Stop FaviconHandler from querying GetActiveFaviconValidity() part 2/2 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@favicon_remove_validity_check
Patch Set: Created 5 years, 2 months 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 unified diff | Download patch
« no previous file with comments | « components/favicon/ios/web_favicon_driver.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/favicon/ios/web_favicon_driver.h" 5 #include "components/favicon/ios/web_favicon_driver.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "components/favicon/core/favicon_url.h" 8 #include "components/favicon/core/favicon_url.h"
9 #include "components/favicon/ios/favicon_url_util.h" 9 #include "components/favicon/ios/favicon_url_util.h"
10 #include "ios/web/public/browser_state.h" 10 #include "ios/web/public/browser_state.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 DCHECK(web_state()); 65 DCHECK(web_state());
66 return web_state()->GetBrowserState()->IsOffTheRecord(); 66 return web_state()->GetBrowserState()->IsOffTheRecord();
67 } 67 }
68 68
69 GURL WebFaviconDriver::GetActiveURL() { 69 GURL WebFaviconDriver::GetActiveURL() {
70 web::NavigationItem* item = 70 web::NavigationItem* item =
71 web_state()->GetNavigationManager()->GetVisibleItem(); 71 web_state()->GetNavigationManager()->GetVisibleItem();
72 return item ? item->GetURL() : GURL(); 72 return item ? item->GetURL() : GURL();
73 } 73 }
74 74
75 bool WebFaviconDriver::GetActiveFaviconValidity() {
76 return !ActiveURLChangedSinceFetchFavicon() && GetFaviconStatus().valid;
77 }
78
79 void WebFaviconDriver::SetActiveFaviconValidity(bool validity) { 75 void WebFaviconDriver::SetActiveFaviconValidity(bool validity) {
80 GetFaviconStatus().valid = validity; 76 GetFaviconStatus().valid = validity;
81 } 77 }
82 78
83 GURL WebFaviconDriver::GetActiveFaviconURL() { 79 GURL WebFaviconDriver::GetActiveFaviconURL() {
84 return ActiveURLChangedSinceFetchFavicon() ? GURL() : GetFaviconStatus().url; 80 return GetFaviconStatus().url;
85 } 81 }
86 82
87 void WebFaviconDriver::SetActiveFaviconURL(const GURL& url) { 83 void WebFaviconDriver::SetActiveFaviconURL(const GURL& url) {
88 GetFaviconStatus().url = url; 84 GetFaviconStatus().url = url;
89 } 85 }
90 86
91 void WebFaviconDriver::SetActiveFaviconImage(const gfx::Image& image) { 87 void WebFaviconDriver::SetActiveFaviconImage(const gfx::Image& image) {
92 GetFaviconStatus().image = image; 88 GetFaviconStatus().image = image;
93 } 89 }
94 90
95 bool WebFaviconDriver::ActiveURLChangedSinceFetchFavicon() {
96 // On iOS the active URL can change in between calls to FetchFavicon(). For
97 // instance, FetchFavicon() is not synchronously called when the active URL
98 // changes as a result of CRWSessionController::goToEntry().
99 // TODO(stuartmorgan): Remove this once iOS always triggers favicon fetches
100 // synchronously after active URL changes.
101 return GetActiveURL() != fetch_favicon_url_;
102 }
103
104 web::FaviconStatus& WebFaviconDriver::GetFaviconStatus() { 91 web::FaviconStatus& WebFaviconDriver::GetFaviconStatus() {
105 DCHECK(!ActiveURLChangedSinceFetchFavicon()); 92 DCHECK(web_state()->GetNavigationManager()->GetVisibleItem());
106 return web_state()->GetNavigationManager()->GetVisibleItem()->GetFavicon(); 93 return web_state()->GetNavigationManager()->GetVisibleItem()->GetFavicon();
107 } 94 }
108 95
109 WebFaviconDriver::WebFaviconDriver(web::WebState* web_state, 96 WebFaviconDriver::WebFaviconDriver(web::WebState* web_state,
110 FaviconService* favicon_service, 97 FaviconService* favicon_service,
111 history::HistoryService* history_service, 98 history::HistoryService* history_service,
112 bookmarks::BookmarkModel* bookmark_model) 99 bookmarks::BookmarkModel* bookmark_model)
113 : web::WebStateObserver(web_state), 100 : web::WebStateObserver(web_state),
114 FaviconDriverImpl(favicon_service, history_service, bookmark_model) { 101 FaviconDriverImpl(favicon_service, history_service, bookmark_model) {
115 } 102 }
116 103
117 WebFaviconDriver::~WebFaviconDriver() { 104 WebFaviconDriver::~WebFaviconDriver() {
118 } 105 }
119 106
120 void WebFaviconDriver::FaviconUrlUpdated( 107 void WebFaviconDriver::FaviconUrlUpdated(
121 const std::vector<web::FaviconURL>& candidates) { 108 const std::vector<web::FaviconURL>& candidates) {
122 DCHECK(!candidates.empty()); 109 DCHECK(!candidates.empty());
123 OnUpdateFaviconURL(GetActiveURL(), FaviconURLsFromWebFaviconURLs(candidates)); 110 OnUpdateFaviconURL(GetActiveURL(), FaviconURLsFromWebFaviconURLs(candidates));
124 } 111 }
125 112
126 } // namespace favicon 113 } // namespace favicon
OLDNEW
« no previous file with comments | « 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