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

Side by Side Diff: chrome/browser/favicon/favicon_tab_helper.cc

Issue 14322023: Don't request missing favicon on every page request. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed punctuation in comments. Created 7 years, 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/favicon/favicon_tab_helper.h" 5 #include "chrome/browser/favicon/favicon_tab_helper.h"
6 6
7 #include "chrome/browser/favicon/favicon_handler.h" 7 #include "chrome/browser/favicon/favicon_handler.h"
8 #include "chrome/browser/favicon/favicon_service_factory.h" 8 #include "chrome/browser/favicon/favicon_service_factory.h"
9 #include "chrome/browser/favicon/favicon_util.h" 9 #include "chrome/browser/favicon/favicon_util.h"
10 #include "chrome/browser/history/history_service.h" 10 #include "chrome/browser/history/history_service.h"
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 } 128 }
129 service->SetFavicons(entry->GetURL(), favicon.url, history::FAVICON, 129 service->SetFavicons(entry->GetURL(), favicon.url, history::FAVICON,
130 favicon.image); 130 favicon.image);
131 } 131 }
132 132
133 NavigationEntry* FaviconTabHelper::GetActiveEntry() { 133 NavigationEntry* FaviconTabHelper::GetActiveEntry() {
134 return web_contents()->GetController().GetActiveEntry(); 134 return web_contents()->GetController().GetActiveEntry();
135 } 135 }
136 136
137 int FaviconTabHelper::StartDownload(const GURL& url, int image_size) { 137 int FaviconTabHelper::StartDownload(const GURL& url, int image_size) {
138 FaviconService* favicon_service = FaviconServiceFactory::GetForProfile(
139 profile_->GetOriginalProfile(), Profile::IMPLICIT_ACCESS);
140 if (favicon_service && favicon_service->WasUnableToDownloadFavicon(url)) {
141 DVLOG(1) << "Skip Failed FavIcon: " << url;
142 return 0;
143 }
144
138 return web_contents()->DownloadImage( 145 return web_contents()->DownloadImage(
139 url, 146 url,
140 true, 147 true,
141 image_size, 148 image_size,
142 base::Bind(&FaviconTabHelper::DidDownloadFavicon,base::Unretained(this))); 149 base::Bind(&FaviconTabHelper::DidDownloadFavicon,base::Unretained(this)));
143 } 150 }
144 151
145 void FaviconTabHelper::NotifyFaviconUpdated(bool icon_url_changed) { 152 void FaviconTabHelper::NotifyFaviconUpdated(bool icon_url_changed) {
146 content::NotificationService::current()->Notify( 153 content::NotificationService::current()->Notify(
147 chrome::NOTIFICATION_FAVICON_UPDATED, 154 chrome::NOTIFICATION_FAVICON_UPDATED,
148 content::Source<WebContents>(web_contents()), 155 content::Source<WebContents>(web_contents()),
149 content::Details<bool>(&icon_url_changed)); 156 content::Details<bool>(&icon_url_changed));
150 web_contents()->NotifyNavigationStateChanged(content::INVALIDATE_TYPE_TAB); 157 web_contents()->NotifyNavigationStateChanged(content::INVALIDATE_TYPE_TAB);
151 } 158 }
152 159
153 void FaviconTabHelper::NavigateToPendingEntry( 160 void FaviconTabHelper::NavigateToPendingEntry(
154 const GURL& url, 161 const GURL& url,
155 NavigationController::ReloadType reload_type) { 162 NavigationController::ReloadType reload_type) {
156 if (reload_type != NavigationController::NO_RELOAD && 163 if (reload_type != NavigationController::NO_RELOAD &&
157 !profile_->IsOffTheRecord()) { 164 !profile_->IsOffTheRecord()) {
158 FaviconService* favicon_service = FaviconServiceFactory::GetForProfile( 165 FaviconService* favicon_service = FaviconServiceFactory::GetForProfile(
159 profile_, Profile::IMPLICIT_ACCESS); 166 profile_, Profile::IMPLICIT_ACCESS);
160 if (favicon_service) 167 if (favicon_service) {
161 favicon_service->SetFaviconOutOfDateForPage(url); 168 favicon_service->SetFaviconOutOfDateForPage(url);
169 if (reload_type == NavigationController::RELOAD_IGNORING_CACHE)
170 favicon_service->ClearUnableToDownloadFavicons();
171 }
162 } 172 }
163 } 173 }
164 174
165 void FaviconTabHelper::DidNavigateMainFrame( 175 void FaviconTabHelper::DidNavigateMainFrame(
166 const content::LoadCommittedDetails& details, 176 const content::LoadCommittedDetails& details,
167 const content::FrameNavigateParams& params) { 177 const content::FrameNavigateParams& params) {
168 // Get the favicon, either from history or request it from the net. 178 // Get the favicon, either from history or request it from the net.
169 FetchFavicon(details.entry->GetURL()); 179 FetchFavicon(details.entry->GetURL());
170 } 180 }
171 181
172 void FaviconTabHelper::DidUpdateFaviconURL( 182 void FaviconTabHelper::DidUpdateFaviconURL(
173 int32 page_id, 183 int32 page_id,
174 const std::vector<content::FaviconURL>& candidates) { 184 const std::vector<content::FaviconURL>& candidates) {
175 favicon_handler_->OnUpdateFaviconURL(page_id, candidates); 185 favicon_handler_->OnUpdateFaviconURL(page_id, candidates);
176 if (touch_icon_handler_.get()) 186 if (touch_icon_handler_.get())
177 touch_icon_handler_->OnUpdateFaviconURL(page_id, candidates); 187 touch_icon_handler_->OnUpdateFaviconURL(page_id, candidates);
178 } 188 }
179 189
180 void FaviconTabHelper::DidDownloadFavicon( 190 void FaviconTabHelper::DidDownloadFavicon(
181 int id, 191 int id,
192 int http_status_code,
182 const GURL& image_url, 193 const GURL& image_url,
183 int requested_size, 194 int requested_size,
184 const std::vector<SkBitmap>& bitmaps) { 195 const std::vector<SkBitmap>& bitmaps) {
196
197 if (bitmaps.empty() && http_status_code == 404) {
palmer 2013/05/13 17:22:47 Maybe not just 404, but any 400 error code? I don'
mef 2013/05/14 18:47:08 Initial CL did the same as Firefox - marked Favico
198 DVLOG(1) << "Failed to Download Favicon:" << image_url;
199 FaviconService* favicon_service = FaviconServiceFactory::GetForProfile(
200 profile_->GetOriginalProfile(), Profile::IMPLICIT_ACCESS);
201 if (favicon_service)
202 favicon_service->UnableToDownloadFavicon(image_url);
203 }
204
185 favicon_handler_->OnDidDownloadFavicon( 205 favicon_handler_->OnDidDownloadFavicon(
186 id, image_url, requested_size, bitmaps); 206 id, image_url, requested_size, bitmaps);
187 if (touch_icon_handler_.get()) { 207 if (touch_icon_handler_.get()) {
188 touch_icon_handler_->OnDidDownloadFavicon( 208 touch_icon_handler_->OnDidDownloadFavicon(
189 id, image_url, requested_size, bitmaps); 209 id, image_url, requested_size, bitmaps);
190 } 210 }
191 } 211 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698