Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/favicon/core/large_icon_service.h" | 5 #include "components/favicon/core/large_icon_service.h" |
| 6 | 6 |
| 7 #include "components/favicon/core/favicon_service.h" | 7 #include "components/favicon/core/favicon_service.h" |
| 8 #include "components/favicon_base/fallback_icon_style.h" | 8 #include "components/favicon_base/fallback_icon_style.h" |
| 9 #include "components/favicon_base/favicon_types.h" | 9 #include "components/favicon_base/favicon_types.h" |
| 10 | 10 |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 40 } | 40 } |
| 41 | 41 |
| 42 void LargeIconService::RunLargeIconCallback( | 42 void LargeIconService::RunLargeIconCallback( |
| 43 const favicon_base::LargeIconCallback& callback, | 43 const favicon_base::LargeIconCallback& callback, |
| 44 int desired_size_in_pixel, | 44 int desired_size_in_pixel, |
| 45 const favicon_base::FaviconRawBitmapResult& bitmap_result) { | 45 const favicon_base::FaviconRawBitmapResult& bitmap_result) { |
| 46 // If there are no bitmaps, return a result with an empty |bitmap| and a | 46 // If there are no bitmaps, return a result with an empty |bitmap| and a |
| 47 // default |fallback_icon_style|. | 47 // default |fallback_icon_style|. |
| 48 favicon_base::LargeIconResult result; | 48 favicon_base::LargeIconResult result; |
| 49 if (!bitmap_result.is_valid()) { | 49 if (!bitmap_result.is_valid()) { |
| 50 result.fallback_icon_style.reset(new favicon_base::FallbackIconStyle()); | |
|
pkotwicz
2015/04/27 17:49:02
Sorry that I missed this. How about adding two new
huangs
2015/04/27 18:16:04
Done.
| |
| 50 callback.Run(result); | 51 callback.Run(result); |
| 51 return; | 52 return; |
| 52 } | 53 } |
| 53 | 54 |
| 54 // If there is a bitmap but it's smaller than the requested size or | 55 // If there is a bitmap but it's smaller than the requested size or |
| 55 // non-square, compute its dominant color and use it as background in | 56 // non-square, compute its dominant color and use it as background in |
| 56 // |fallback_icon_style|. | 57 // |fallback_icon_style|. |
| 57 if (bitmap_result.pixel_size.width() < desired_size_in_pixel || | 58 if (bitmap_result.pixel_size.width() < desired_size_in_pixel || |
| 58 bitmap_result.pixel_size.height() < desired_size_in_pixel || | 59 bitmap_result.pixel_size.height() < desired_size_in_pixel || |
| 59 bitmap_result.pixel_size.width() != bitmap_result.pixel_size.height()) { | 60 bitmap_result.pixel_size.width() != bitmap_result.pixel_size.height()) { |
| 60 // TODO(beaudoin): Resize the icon if it's large enough. Alternatively, | 61 // TODO(beaudoin): Resize the icon if it's large enough. Alternatively, |
| 61 // return it and let the HTML resize it. | 62 // return it and let the HTML resize it. |
| 62 result.fallback_icon_style.reset(new favicon_base::FallbackIconStyle()); | 63 result.fallback_icon_style.reset(new favicon_base::FallbackIconStyle()); |
| 63 favicon_base::SetDominantColorAsBackground( | 64 favicon_base::SetDominantColorAsBackground( |
| 64 bitmap_result.bitmap_data, result.fallback_icon_style.get()); | 65 bitmap_result.bitmap_data, result.fallback_icon_style.get()); |
| 65 callback.Run(result); | 66 callback.Run(result); |
| 66 return; | 67 return; |
| 67 } | 68 } |
| 68 | 69 |
| 69 // The bitmap is square and at least as large as the requested one, return | 70 // The bitmap is square and at least as large as the requested one, return |
| 70 // it. | 71 // it. |
| 71 // TODO(beaudoin): Resize the icon if it's too large. Alternatively, return | 72 // TODO(beaudoin): Resize the icon if it's too large. Alternatively, return |
| 72 // it and let the HTML resize it. | 73 // it and let the HTML resize it. |
| 73 result.bitmap = bitmap_result; | 74 result.bitmap = bitmap_result; |
| 74 callback.Run(result); | 75 callback.Run(result); |
| 75 } | 76 } |
| 76 | 77 |
| 77 } // namespace favicon | 78 } // namespace favicon |
| OLD | NEW |