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

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: Addressed codereview comments, fixed crash in Incognito mode. 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
« no previous file with comments | « chrome/browser/favicon/favicon_service.cc ('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 (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->IsMissingFavicon(url)) {
141 VLOG(1) << "Skip Missing 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,
(...skipping 27 matching lines...) Expand all
175 favicon_handler_->OnUpdateFaviconURL(page_id, candidates); 182 favicon_handler_->OnUpdateFaviconURL(page_id, candidates);
176 if (touch_icon_handler_.get()) 183 if (touch_icon_handler_.get())
177 touch_icon_handler_->OnUpdateFaviconURL(page_id, candidates); 184 touch_icon_handler_->OnUpdateFaviconURL(page_id, candidates);
178 } 185 }
179 186
180 void FaviconTabHelper::DidDownloadFavicon( 187 void FaviconTabHelper::DidDownloadFavicon(
181 int id, 188 int id,
182 const GURL& image_url, 189 const GURL& image_url,
183 int requested_size, 190 int requested_size,
184 const std::vector<SkBitmap>& bitmaps) { 191 const std::vector<SkBitmap>& bitmaps) {
192
193 if (bitmaps.size() == 0) {
sky 2013/05/01 14:00:07 Under what circumstances should we be doing this?
mef 2013/05/01 15:20:15 My (possibly incorrect) understanding is that bitm
194 VLOG(1) << "Missing Favicon:" << image_url;
195 FaviconService* favicon_service = FaviconServiceFactory::GetForProfile(
196 profile_->GetOriginalProfile(), Profile::IMPLICIT_ACCESS);
197 if (favicon_service)
198 favicon_service->AddMissingFavicon(image_url);
199 }
200
185 favicon_handler_->OnDidDownloadFavicon( 201 favicon_handler_->OnDidDownloadFavicon(
186 id, image_url, requested_size, bitmaps); 202 id, image_url, requested_size, bitmaps);
187 if (touch_icon_handler_.get()) { 203 if (touch_icon_handler_.get()) {
188 touch_icon_handler_->OnDidDownloadFavicon( 204 touch_icon_handler_->OnDidDownloadFavicon(
189 id, image_url, requested_size, bitmaps); 205 id, image_url, requested_size, bitmaps);
190 } 206 }
191 } 207 }
OLDNEW
« no previous file with comments | « chrome/browser/favicon/favicon_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698