Commit 5adfb2a5 authored by huangs's avatar huangs Committed by Commit bot

[Local NTP] Fix chrome://large-icon fallback when no favicon is found.

For chrome://large-icon, if no large icon is found then we get the small
favicon to extract the dominant color for fallback background. If the
favicon is missing we're supposed to have a gray background. This behavior
was broken and this CL fixes it.

BUG=467712

Review URL: https://codereview.chromium.org/1108833002

Cr-Commit-Position: refs/heads/master@{#327119}
parent 4d64d862
...@@ -45,9 +45,9 @@ void LargeIconService::RunLargeIconCallback( ...@@ -45,9 +45,9 @@ void LargeIconService::RunLargeIconCallback(
const favicon_base::FaviconRawBitmapResult& bitmap_result) { const favicon_base::FaviconRawBitmapResult& bitmap_result) {
// If there are no bitmaps, return a result with an empty |bitmap| and a // If there are no bitmaps, return a result with an empty |bitmap| and a
// default |fallback_icon_style|. // default |fallback_icon_style|.
favicon_base::LargeIconResult result;
if (!bitmap_result.is_valid()) { if (!bitmap_result.is_valid()) {
callback.Run(result); callback.Run(
favicon_base::LargeIconResult(new favicon_base::FallbackIconStyle()));
return; return;
} }
...@@ -59,7 +59,7 @@ void LargeIconService::RunLargeIconCallback( ...@@ -59,7 +59,7 @@ void LargeIconService::RunLargeIconCallback(
bitmap_result.pixel_size.width() != bitmap_result.pixel_size.height()) { bitmap_result.pixel_size.width() != bitmap_result.pixel_size.height()) {
// TODO(beaudoin): Resize the icon if it's large enough. Alternatively, // TODO(beaudoin): Resize the icon if it's large enough. Alternatively,
// return it and let the HTML resize it. // return it and let the HTML resize it.
result.fallback_icon_style.reset(new favicon_base::FallbackIconStyle()); favicon_base::LargeIconResult result(new favicon_base::FallbackIconStyle());
favicon_base::SetDominantColorAsBackground( favicon_base::SetDominantColorAsBackground(
bitmap_result.bitmap_data, result.fallback_icon_style.get()); bitmap_result.bitmap_data, result.fallback_icon_style.get());
callback.Run(result); callback.Run(result);
...@@ -70,8 +70,7 @@ void LargeIconService::RunLargeIconCallback( ...@@ -70,8 +70,7 @@ void LargeIconService::RunLargeIconCallback(
// it. // it.
// TODO(beaudoin): Resize the icon if it's too large. Alternatively, return // TODO(beaudoin): Resize the icon if it's too large. Alternatively, return
// it and let the HTML resize it. // it and let the HTML resize it.
result.bitmap = bitmap_result; callback.Run(favicon_base::LargeIconResult(bitmap_result));
callback.Run(result);
} }
} // namespace favicon } // namespace favicon
...@@ -27,7 +27,11 @@ FaviconRawBitmapResult::~FaviconRawBitmapResult() {} ...@@ -27,7 +27,11 @@ FaviconRawBitmapResult::~FaviconRawBitmapResult() {}
// -------------------------------------------------------- // --------------------------------------------------------
// LargeIconResult // LargeIconResult
LargeIconResult::LargeIconResult() {} LargeIconResult::LargeIconResult(const FaviconRawBitmapResult& bitmap_in)
: bitmap(bitmap_in) {}
LargeIconResult::LargeIconResult(FallbackIconStyle* fallback_icon_style_in)
: fallback_icon_style(fallback_icon_style_in) {}
LargeIconResult::~LargeIconResult() {} LargeIconResult::~LargeIconResult() {}
......
...@@ -79,7 +79,11 @@ typedef FaviconRawBitmapResult FaviconRawBitmapData; ...@@ -79,7 +79,11 @@ typedef FaviconRawBitmapResult FaviconRawBitmapData;
// either the bitmap data if the favicon database has a sufficiently large // either the bitmap data if the favicon database has a sufficiently large
// favicon bitmap and the style of the fallback icon otherwise. // favicon bitmap and the style of the fallback icon otherwise.
struct LargeIconResult { struct LargeIconResult {
LargeIconResult(); explicit LargeIconResult(const FaviconRawBitmapResult& bitmap_in);
// Takes ownership of |fallback_icon_style_in|.
explicit LargeIconResult(FallbackIconStyle* fallback_icon_style_in);
~LargeIconResult(); ~LargeIconResult();
// The bitmap from the favicon database if the database has a sufficiently // The bitmap from the favicon database if the database has a sufficiently
......
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