Chromium Code Reviews| Index: components/favicon/content/content_favicon_driver.cc |
| diff --git a/components/favicon/content/content_favicon_driver.cc b/components/favicon/content/content_favicon_driver.cc |
| index 413517ad0da1c3713446e0cd39bdad07c2a45c63..4ba87d3c1866a3ac9f25cdfd5309b77a8e1c13fe 100644 |
| --- a/components/favicon/content/content_favicon_driver.cc |
| +++ b/components/favicon/content/content_favicon_driver.cc |
| @@ -16,9 +16,36 @@ |
| #include "content/public/browser/navigation_entry.h" |
| #include "content/public/common/favicon_url.h" |
| #include "ui/gfx/image/image.h" |
| +#include "ui/gfx/image/image_skia.h" |
| +#include "ui/gfx/image/image_skia_operations.h" |
| DEFINE_WEB_CONTENTS_USER_DATA_KEY(favicon::ContentFaviconDriver); |
| +#if defined(OS_MACOSX) || defined(TOOLKIT_VIEWS) |
| + |
| +namespace { |
| + |
| +// Desaturate favicon HSL shift values. |
| +const double kDesaturateHue = -1.0; |
| +const double kDesaturateSaturation = 0.0; |
| +const double kDesaturateLightness = 0.6; |
| + |
| +gfx::Image GetDesaturatedFavicon(gfx::Image favicon) { |
| + color_utils::HSL shift = {kDesaturateHue, kDesaturateSaturation, |
| + kDesaturateLightness}; |
| + const gfx::ImageSkia* image = favicon.ToImageSkia(); |
| + if (image) { |
|
Nico
2016/09/15 16:58:37
Can this ever be not true? I thought ToImageSkia()
spqchan
2016/09/15 22:07:04
Sure thing, I was just cautious
|
| + return gfx::Image( |
| + gfx::ImageSkiaOperations::CreateHSLShiftedImage(*image, shift)); |
| + } |
| + |
| + return favicon; |
| +} |
| + |
| +} // namespace |
| + |
| +#endif |
| + |
| namespace favicon { |
| // static |
| @@ -68,8 +95,18 @@ gfx::Image ContentFaviconDriver::GetFavicon() const { |
| return entry->GetFavicon().image; |
| entry = controller.GetLastCommittedEntry(); |
| - if (entry) |
| - return entry->GetFavicon().image; |
| + if (entry) { |
| + gfx::Image image = entry->GetFavicon().image; |
| + |
| +#if defined(OS_MACOSX) || defined(TOOLKIT_VIEWS) |
| + bool network_error = !web_contents()->IsLoadingToDifferentDocument() && |
| + entry->GetPageType() == content::PAGE_TYPE_ERROR; |
| + if (network_error) |
| + return GetDesaturatedFavicon(image); |
| +#endif |
| + |
| + return image; |
| + } |
| return gfx::Image(); |
| } |