| 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_handler.h" | 5 #include "chrome/browser/favicon/favicon_handler.h" |
| 6 | 6 |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
| 13 #include "base/memory/ref_counted_memory.h" | 13 #include "base/memory/ref_counted_memory.h" |
| 14 #include "chrome/browser/bookmarks/bookmark_model.h" | 14 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 15 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 15 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 16 #include "chrome/browser/favicon/favicon_service_factory.h" | |
| 17 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
| 18 #include "chrome/common/icon_messages.h" | 17 #include "chrome/common/icon_messages.h" |
| 19 #include "content/public/browser/favicon_status.h" | 18 #include "content/public/browser/favicon_status.h" |
| 20 #include "content/public/browser/navigation_entry.h" | 19 #include "content/public/browser/navigation_entry.h" |
| 21 #include "skia/ext/image_operations.h" | 20 #include "skia/ext/image_operations.h" |
| 22 #include "ui/gfx/codec/png_codec.h" | 21 #include "ui/gfx/codec/png_codec.h" |
| 23 #include "ui/gfx/image/image.h" | 22 #include "ui/gfx/image/image.h" |
| 24 #include "ui/gfx/image/image_util.h" | 23 #include "ui/gfx/image/image_util.h" |
| 25 | 24 |
| 26 using content::NavigationEntry; | 25 using content::NavigationEntry; |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 | 150 |
| 152 int FaviconHandler::DownloadImage( | 151 int FaviconHandler::DownloadImage( |
| 153 const GURL& image_url, | 152 const GURL& image_url, |
| 154 int image_size, | 153 int image_size, |
| 155 history::IconType icon_type, | 154 history::IconType icon_type, |
| 156 const FaviconTabHelper::ImageDownloadCallback& callback) { | 155 const FaviconTabHelper::ImageDownloadCallback& callback) { |
| 157 return ScheduleDownload(GURL(), image_url, image_size, icon_type, callback); | 156 return ScheduleDownload(GURL(), image_url, image_size, icon_type, callback); |
| 158 } | 157 } |
| 159 | 158 |
| 160 FaviconService* FaviconHandler::GetFaviconService() { | 159 FaviconService* FaviconHandler::GetFaviconService() { |
| 161 return FaviconServiceFactory::GetForProfile( | 160 return profile_->GetFaviconService(Profile::EXPLICIT_ACCESS); |
| 162 profile_, Profile::EXPLICIT_ACCESS); | |
| 163 } | 161 } |
| 164 | 162 |
| 165 bool FaviconHandler::UpdateFaviconCandidate(const GURL& url, | 163 bool FaviconHandler::UpdateFaviconCandidate(const GURL& url, |
| 166 const GURL& image_url, | 164 const GURL& image_url, |
| 167 const gfx::Image& image, | 165 const gfx::Image& image, |
| 168 float score, | 166 float score, |
| 169 history::IconType icon_type) { | 167 history::IconType icon_type) { |
| 170 bool update_candidate = false; | 168 bool update_candidate = false; |
| 171 SkBitmap bitmap = *(image.ToSkBitmap()); | 169 SkBitmap bitmap = *(image.ToSkBitmap()); |
| 172 bool exact_match = score == 1; | 170 bool exact_match = score == 1; |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 CancelableRequestConsumerBase* consumer, | 365 CancelableRequestConsumerBase* consumer, |
| 368 const FaviconService::FaviconDataCallback& callback) { | 366 const FaviconService::FaviconDataCallback& callback) { |
| 369 GetFaviconService()->GetFavicon(icon_url, icon_type, consumer, callback); | 367 GetFaviconService()->GetFavicon(icon_url, icon_type, consumer, callback); |
| 370 } | 368 } |
| 371 | 369 |
| 372 void FaviconHandler::GetFaviconForURL( | 370 void FaviconHandler::GetFaviconForURL( |
| 373 const GURL& page_url, | 371 const GURL& page_url, |
| 374 int icon_types, | 372 int icon_types, |
| 375 CancelableRequestConsumerBase* consumer, | 373 CancelableRequestConsumerBase* consumer, |
| 376 const FaviconService::FaviconDataCallback& callback) { | 374 const FaviconService::FaviconDataCallback& callback) { |
| 377 GetFaviconService()->GetFaviconForURL(profile_, page_url, icon_types, | 375 GetFaviconService()->GetFaviconForURL(page_url, icon_types, consumer, |
| 378 consumer, callback); | 376 callback); |
| 379 } | 377 } |
| 380 | 378 |
| 381 void FaviconHandler::SetHistoryFavicon( | 379 void FaviconHandler::SetHistoryFavicon( |
| 382 const GURL& page_url, | 380 const GURL& page_url, |
| 383 const GURL& icon_url, | 381 const GURL& icon_url, |
| 384 const std::vector<unsigned char>& image_data, | 382 const std::vector<unsigned char>& image_data, |
| 385 history::IconType icon_type) { | 383 history::IconType icon_type) { |
| 386 GetFaviconService()->SetFavicon(page_url, icon_url, image_data, icon_type); | 384 GetFaviconService()->SetFavicon(page_url, icon_url, image_data, icon_type); |
| 387 } | 385 } |
| 388 | 386 |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 534 int height = bitmap.height(); | 532 int height = bitmap.height(); |
| 535 if (width > 0 && height > 0) { | 533 if (width > 0 && height > 0) { |
| 536 gfx::CalculateFaviconTargetSize(&width, &height); | 534 gfx::CalculateFaviconTargetSize(&width, &height); |
| 537 return gfx::Image(skia::ImageOperations::Resize( | 535 return gfx::Image(skia::ImageOperations::Resize( |
| 538 bitmap, skia::ImageOperations::RESIZE_LANCZOS3, | 536 bitmap, skia::ImageOperations::RESIZE_LANCZOS3, |
| 539 width, height)); | 537 width, height)); |
| 540 } | 538 } |
| 541 | 539 |
| 542 return image; | 540 return image; |
| 543 } | 541 } |
| OLD | NEW |