Chromium Code Reviews| Index: chrome/browser/ui/webui/large_icon_source.cc |
| diff --git a/chrome/browser/ui/webui/large_icon_source.cc b/chrome/browser/ui/webui/large_icon_source.cc |
| index df1e285f6c307e717c86b2056980cffeed9f7785..b073c9787ee641e0820c72ba4e5f75bccd3e6733 100644 |
| --- a/chrome/browser/ui/webui/large_icon_source.cc |
| +++ b/chrome/browser/ui/webui/large_icon_source.cc |
| @@ -13,15 +13,12 @@ |
| #include "components/favicon_base/fallback_icon_style.h" |
| #include "net/url_request/url_request.h" |
| #include "third_party/skia/include/core/SkColor.h" |
| -#include "ui/gfx/color_analysis.h" |
| -#include "ui/gfx/color_utils.h" |
| namespace { |
| const int kDefaultLargeIconSize = 96; |
| const int kMaxLargeIconSize = 192; // Arbitrary bound to safeguard endpoint. |
| -const double kMaxBackgroundLuminance = 0.67; |
| const SkColor kDarkGray = SkColorSetRGB(0x78, 0x78, 0x78); |
| const SkColor kTextColor = SK_ColorWHITE; |
| const SkColor kDefaultBackgroundColor = kDarkGray; |
| @@ -48,9 +45,6 @@ LargeIconSource::LargeIconSource( |
| favicon::FallbackIconService* fallback_icon_service) |
| : favicon_service_(favicon_service), |
| fallback_icon_service_(fallback_icon_service) { |
| - large_icon_types_.push_back(favicon_base::IconType::FAVICON); |
| - large_icon_types_.push_back(favicon_base::IconType::TOUCH_ICON); |
| - large_icon_types_.push_back(favicon_base::IconType::TOUCH_PRECOMPOSED_ICON); |
| } |
| LargeIconSource::~LargeIconSource() { |
| @@ -85,9 +79,8 @@ void LargeIconSource::StartDataRequest( |
| return; |
| } |
| - favicon_service_->GetLargestRawFaviconForPageURL( |
| + favicon_service_->getLargeIcon( |
|
huangs
2015/04/17 03:55:17
NIT: GetLargeIcon()
beaudoin
2015/04/17 14:50:52
Done.
|
| url, |
| - large_icon_types_, |
| parser.size_in_pixels(), |
| base::Bind( |
| &LargeIconSource::OnIconDataAvailable, |
| @@ -117,30 +110,18 @@ bool LargeIconSource::ShouldServiceRequest( |
| void LargeIconSource::OnIconDataAvailable( |
| const IconRequest& request, |
| - const favicon_base::FaviconRawBitmapResult& bitmap_result) { |
| - if (!bitmap_result.is_valid()) { |
| - SendDefaultFallbackIcon(request); |
| + const favicon_base::LargeIconResult& result) { |
| + if (result.bitmap.is_valid()) { |
| + request.callback.Run(result.bitmap.bitmap_data.get()); |
| return; |
| } |
| - // If we found a bitmap, but it's smaller than the requested size, we |
| - // generate a fallback using the dominant color from the too-small bitmap. |
| - // We adjust the luminance of the background so we can put light text over it. |
| - if (bitmap_result.pixel_size.width() < request.size || |
| - bitmap_result.pixel_size.height() < request.size) { |
| - SkColor background = |
| - color_utils::CalculateKMeanColorOfPNG(bitmap_result.bitmap_data); |
| - color_utils::HSL background_hsl; |
| - color_utils::SkColorToHSL(background, &background_hsl); |
| - background_hsl.l = std::min(background_hsl.l, kMaxBackgroundLuminance); |
| - background = color_utils::HSLToSkColor(background_hsl, SK_AlphaOPAQUE); |
| - |
| - // Now we can construct the fallback icon. |
| - SendFallbackIcon(request, kTextColor, background); |
| + if (result.is_color_valid()) { |
| + SendFallbackIcon(request, kTextColor, result.dominant_color); |
| return; |
| } |
| - request.callback.Run(bitmap_result.bitmap_data.get()); |
| + SendDefaultFallbackIcon(request); |
| } |
| void LargeIconSource::SendDefaultFallbackIcon(const IconRequest& request) { |