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 27 matching lines...) Expand all Loading... |
38 base::Unretained(this), callback, desired_size_in_pixel), | 38 base::Unretained(this), callback, desired_size_in_pixel), |
39 tracker); | 39 tracker); |
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; | |
49 if (!bitmap_result.is_valid()) { | 48 if (!bitmap_result.is_valid()) { |
50 callback.Run(result); | 49 callback.Run( |
| 50 favicon_base::LargeIconResult(new favicon_base::FallbackIconStyle())); |
51 return; | 51 return; |
52 } | 52 } |
53 | 53 |
54 // If there is a bitmap but it's smaller than the requested size or | 54 // 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 | 55 // non-square, compute its dominant color and use it as background in |
56 // |fallback_icon_style|. | 56 // |fallback_icon_style|. |
57 if (bitmap_result.pixel_size.width() < desired_size_in_pixel || | 57 if (bitmap_result.pixel_size.width() < desired_size_in_pixel || |
58 bitmap_result.pixel_size.height() < desired_size_in_pixel || | 58 bitmap_result.pixel_size.height() < desired_size_in_pixel || |
59 bitmap_result.pixel_size.width() != bitmap_result.pixel_size.height()) { | 59 bitmap_result.pixel_size.width() != bitmap_result.pixel_size.height()) { |
60 // TODO(beaudoin): Resize the icon if it's large enough. Alternatively, | 60 // TODO(beaudoin): Resize the icon if it's large enough. Alternatively, |
61 // return it and let the HTML resize it. | 61 // return it and let the HTML resize it. |
62 result.fallback_icon_style.reset(new favicon_base::FallbackIconStyle()); | 62 favicon_base::LargeIconResult result(new favicon_base::FallbackIconStyle()); |
63 favicon_base::SetDominantColorAsBackground( | 63 favicon_base::SetDominantColorAsBackground( |
64 bitmap_result.bitmap_data, result.fallback_icon_style.get()); | 64 bitmap_result.bitmap_data, result.fallback_icon_style.get()); |
65 callback.Run(result); | 65 callback.Run(result); |
66 return; | 66 return; |
67 } | 67 } |
68 | 68 |
69 // The bitmap is square and at least as large as the requested one, return | 69 // The bitmap is square and at least as large as the requested one, return |
70 // it. | 70 // it. |
71 // TODO(beaudoin): Resize the icon if it's too large. Alternatively, return | 71 // TODO(beaudoin): Resize the icon if it's too large. Alternatively, return |
72 // it and let the HTML resize it. | 72 // it and let the HTML resize it. |
73 result.bitmap = bitmap_result; | 73 callback.Run(favicon_base::LargeIconResult(bitmap_result)); |
74 callback.Run(result); | |
75 } | 74 } |
76 | 75 |
77 } // namespace favicon | 76 } // namespace favicon |
OLD | NEW |