OLD | NEW |
---|---|
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 Loading... | |
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_, Profile::IMPLICIT_ACCESS); | |
140 if (favicon_service && favicon_service->IsMissingFavicon(url)) { | |
141 VLOG(1) << "Skip Missing FavIcon: " << url; | |
mef
2013/04/29 21:55:03
Should I somehow post a call to DidDownloadFavicon
pauljensen
2013/04/30 14:38:04
I have no idea; I am very unfamiliar with the Favi
| |
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 Loading... | |
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) { | |
194 VLOG(1) << "Missing Favicon:" << image_url; | |
195 FaviconService* favicon_service = FaviconServiceFactory::GetForProfile( | |
196 profile_, 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 } |
OLD | NEW |