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/chrome_notification_types.h" | 7 #include "chrome/browser/chrome_notification_types.h" |
8 #include "chrome/browser/favicon/chrome_favicon_client.h" | 8 #include "chrome/browser/favicon/chrome_favicon_client.h" |
9 #include "chrome/browser/favicon/chrome_favicon_client_factory.h" | 9 #include "chrome/browser/favicon/chrome_favicon_client_factory.h" |
10 #include "chrome/browser/favicon/favicon_handler.h" | 10 #include "chrome/browser/favicon/favicon_handler.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
47 #if defined(OS_ANDROID) || defined(OS_IOS) | 47 #if defined(OS_ANDROID) || defined(OS_IOS) |
48 bool download_largest_icon = true; | 48 bool download_largest_icon = true; |
49 #else | 49 #else |
50 bool download_largest_icon = false; | 50 bool download_largest_icon = false; |
51 #endif | 51 #endif |
52 favicon_handler_.reset(new FaviconHandler( | 52 favicon_handler_.reset(new FaviconHandler( |
53 client_, this, FaviconHandler::FAVICON, download_largest_icon)); | 53 client_, this, FaviconHandler::FAVICON, download_largest_icon)); |
54 if (chrome::kEnableTouchIcon) | 54 if (chrome::kEnableTouchIcon) |
55 touch_icon_handler_.reset(new FaviconHandler( | 55 touch_icon_handler_.reset(new FaviconHandler( |
56 client_, this, FaviconHandler::TOUCH, download_largest_icon)); | 56 client_, this, FaviconHandler::TOUCH, download_largest_icon)); |
57 big_icon_handler_.reset( | |
Roger McFarlane (Chromium)
2015/03/16 19:00:59
maybe put these derefs behind a check for null? So
huangs
2015/03/17 01:43:52
Done.
| |
58 new FaviconHandler(client_, this, FaviconHandler::BIG, true)); | |
57 } | 59 } |
58 | 60 |
59 FaviconTabHelper::~FaviconTabHelper() { | 61 FaviconTabHelper::~FaviconTabHelper() { |
60 } | 62 } |
61 | 63 |
62 void FaviconTabHelper::FetchFavicon(const GURL& url) { | 64 void FaviconTabHelper::FetchFavicon(const GURL& url) { |
63 favicon_handler_->FetchFavicon(url); | 65 favicon_handler_->FetchFavicon(url); |
64 if (touch_icon_handler_.get()) | 66 if (touch_icon_handler_.get()) |
65 touch_icon_handler_->FetchFavicon(url); | 67 touch_icon_handler_->FetchFavicon(url); |
68 big_icon_handler_->FetchFavicon(url); | |
66 } | 69 } |
67 | 70 |
68 gfx::Image FaviconTabHelper::GetFavicon() const { | 71 gfx::Image FaviconTabHelper::GetFavicon() const { |
69 // Like GetTitle(), we also want to use the favicon for the last committed | 72 // Like GetTitle(), we also want to use the favicon for the last committed |
70 // entry rather than a pending navigation entry. | 73 // entry rather than a pending navigation entry. |
71 const NavigationController& controller = web_contents()->GetController(); | 74 const NavigationController& controller = web_contents()->GetController(); |
72 NavigationEntry* entry = controller.GetTransientEntry(); | 75 NavigationEntry* entry = controller.GetTransientEntry(); |
73 if (entry) | 76 if (entry) |
74 return entry->GetFavicon().image; | 77 return entry->GetFavicon().image; |
75 | 78 |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
275 for (size_t i = 0; i < candidates.size(); i++) { | 278 for (size_t i = 0; i < candidates.size(); i++) { |
276 const content::FaviconURL& candidate = candidates[i]; | 279 const content::FaviconURL& candidate = candidates[i]; |
277 favicon_urls.push_back( | 280 favicon_urls.push_back( |
278 favicon::FaviconURL(candidate.icon_url, | 281 favicon::FaviconURL(candidate.icon_url, |
279 ToChromeIconType(candidate.icon_type), | 282 ToChromeIconType(candidate.icon_type), |
280 candidate.icon_sizes)); | 283 candidate.icon_sizes)); |
281 } | 284 } |
282 favicon_handler_->OnUpdateFaviconURL(favicon_urls); | 285 favicon_handler_->OnUpdateFaviconURL(favicon_urls); |
283 if (touch_icon_handler_.get()) | 286 if (touch_icon_handler_.get()) |
284 touch_icon_handler_->OnUpdateFaviconURL(favicon_urls); | 287 touch_icon_handler_->OnUpdateFaviconURL(favicon_urls); |
288 big_icon_handler_->OnUpdateFaviconURL(favicon_urls); | |
285 } | 289 } |
286 | 290 |
287 void FaviconTabHelper::DidDownloadFavicon( | 291 void FaviconTabHelper::DidDownloadFavicon( |
288 int id, | 292 int id, |
289 int http_status_code, | 293 int http_status_code, |
290 const GURL& image_url, | 294 const GURL& image_url, |
291 const std::vector<SkBitmap>& bitmaps, | 295 const std::vector<SkBitmap>& bitmaps, |
292 const std::vector<gfx::Size>& original_bitmap_sizes) { | 296 const std::vector<gfx::Size>& original_bitmap_sizes) { |
293 | 297 |
294 if (bitmaps.empty() && http_status_code == 404) { | 298 if (bitmaps.empty() && http_status_code == 404) { |
295 DVLOG(1) << "Failed to Download Favicon:" << image_url; | 299 DVLOG(1) << "Failed to Download Favicon:" << image_url; |
296 FaviconService* favicon_service = FaviconServiceFactory::GetForProfile( | 300 FaviconService* favicon_service = FaviconServiceFactory::GetForProfile( |
297 profile_->GetOriginalProfile(), ServiceAccessType::IMPLICIT_ACCESS); | 301 profile_->GetOriginalProfile(), ServiceAccessType::IMPLICIT_ACCESS); |
298 if (favicon_service) | 302 if (favicon_service) |
299 favicon_service->UnableToDownloadFavicon(image_url); | 303 favicon_service->UnableToDownloadFavicon(image_url); |
300 } | 304 } |
301 | 305 |
302 favicon_handler_->OnDidDownloadFavicon( | 306 favicon_handler_->OnDidDownloadFavicon( |
303 id, image_url, bitmaps, original_bitmap_sizes); | 307 id, image_url, bitmaps, original_bitmap_sizes); |
304 if (touch_icon_handler_.get()) { | 308 if (touch_icon_handler_.get()) { |
305 touch_icon_handler_->OnDidDownloadFavicon( | 309 touch_icon_handler_->OnDidDownloadFavicon( |
306 id, image_url, bitmaps, original_bitmap_sizes); | 310 id, image_url, bitmaps, original_bitmap_sizes); |
307 } | 311 } |
312 big_icon_handler_->OnDidDownloadFavicon( | |
313 id, image_url, bitmaps, original_bitmap_sizes); | |
308 } | 314 } |
OLD | NEW |