diff options
author | huangs <huangs@chromium.org> | 2015-04-27 14:14:20 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-04-27 21:14:12 +0000 |
commit | 5adfb2a5905c9bb71978f45896f39a982ebcddbc (patch) | |
tree | ca93d28088ca84f0d340b5af38f699e502cafb65 | |
parent | 4d64d862917d9cd9e045e95c68a3dd984d4eabcd (diff) | |
download | chromium_src-5adfb2a5905c9bb71978f45896f39a982ebcddbc.zip chromium_src-5adfb2a5905c9bb71978f45896f39a982ebcddbc.tar.gz chromium_src-5adfb2a5905c9bb71978f45896f39a982ebcddbc.tar.bz2 |
[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}
-rw-r--r-- | components/favicon/core/large_icon_service.cc | 9 | ||||
-rw-r--r-- | components/favicon_base/favicon_types.cc | 6 | ||||
-rw-r--r-- | components/favicon_base/favicon_types.h | 6 |
3 files changed, 14 insertions, 7 deletions
diff --git a/components/favicon/core/large_icon_service.cc b/components/favicon/core/large_icon_service.cc index 702761c..9aeb8e8 100644 --- a/components/favicon/core/large_icon_service.cc +++ b/components/favicon/core/large_icon_service.cc @@ -45,9 +45,9 @@ void LargeIconService::RunLargeIconCallback( const favicon_base::FaviconRawBitmapResult& bitmap_result) { // If there are no bitmaps, return a result with an empty |bitmap| and a // default |fallback_icon_style|. - favicon_base::LargeIconResult result; if (!bitmap_result.is_valid()) { - callback.Run(result); + callback.Run( + favicon_base::LargeIconResult(new favicon_base::FallbackIconStyle())); return; } @@ -59,7 +59,7 @@ void LargeIconService::RunLargeIconCallback( bitmap_result.pixel_size.width() != bitmap_result.pixel_size.height()) { // TODO(beaudoin): Resize the icon if it's large enough. Alternatively, // 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( bitmap_result.bitmap_data, result.fallback_icon_style.get()); callback.Run(result); @@ -70,8 +70,7 @@ void LargeIconService::RunLargeIconCallback( // it. // TODO(beaudoin): Resize the icon if it's too large. Alternatively, return // it and let the HTML resize it. - result.bitmap = bitmap_result; - callback.Run(result); + callback.Run(favicon_base::LargeIconResult(bitmap_result)); } } // namespace favicon diff --git a/components/favicon_base/favicon_types.cc b/components/favicon_base/favicon_types.cc index e69f1d7..2ed5eb0 100644 --- a/components/favicon_base/favicon_types.cc +++ b/components/favicon_base/favicon_types.cc @@ -27,7 +27,11 @@ FaviconRawBitmapResult::~FaviconRawBitmapResult() {} // -------------------------------------------------------- // 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() {} diff --git a/components/favicon_base/favicon_types.h b/components/favicon_base/favicon_types.h index f7c812a..469d0fa 100644 --- a/components/favicon_base/favicon_types.h +++ b/components/favicon_base/favicon_types.h @@ -79,7 +79,11 @@ typedef FaviconRawBitmapResult FaviconRawBitmapData; // either the bitmap data if the favicon database has a sufficiently large // favicon bitmap and the style of the fallback icon otherwise. struct LargeIconResult { - LargeIconResult(); + explicit LargeIconResult(const FaviconRawBitmapResult& bitmap_in); + + // Takes ownership of |fallback_icon_style_in|. + explicit LargeIconResult(FallbackIconStyle* fallback_icon_style_in); + ~LargeIconResult(); // The bitmap from the favicon database if the database has a sufficiently |