Commit 3812b6f6 authored by Kristi Park's avatar Kristi Park Committed by Commit Bot

[NTP] Resize prepopulated page favicons if necessary

Previously, the favicons were not resized at all. Add functionality to
resize the favicons to the proper pixel width/height.

Bug: 908051
Change-Id: Ie81f1675575d5d8f66be686db2d78e40124412e8
Reviewed-on: https://chromium-review.googlesource.com/c/1357570
Commit-Queue: Mathieu Perreault <mathp@chromium.org>
Reviewed-by: default avatarMathieu Perreault <mathp@chromium.org>
Cr-Commit-Position: refs/heads/master@{#613093}
parent 99701b2d
......@@ -46,6 +46,7 @@
#include "ui/gfx/font_list.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/image/image.h"
#include "ui/gfx/image/image_skia_operations.h"
#include "url/gurl.h"
namespace {
......@@ -280,7 +281,19 @@ void NtpIconSource::StartDataRequest(
gfx::Image& image =
ui::ResourceBundle::GetSharedInstance().GetImageNamed(
prepopulated_page.favicon_id);
ReturnRenderedIconForRequest(request, image.AsBitmap());
// Resize as necessary.
gfx::Size target_size(icon_size_in_pixels, icon_size_in_pixels);
if (!image.IsEmpty() && image.Size() != target_size) {
gfx::ImageSkia resized_image =
gfx::ImageSkiaOperations::CreateResizedImage(
image.AsImageSkia(), skia::ImageOperations::RESIZE_BEST,
target_size);
ReturnRenderedIconForRequest(request,
gfx::Image(resized_image).AsBitmap());
} else {
ReturnRenderedIconForRequest(request, image.AsBitmap());
}
return;
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment