OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_FAVICON_FAVICON_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_FAVICON_FAVICON_SERVICE_H_ |
6 #define CHROME_BROWSER_FAVICON_FAVICON_SERVICE_H_ | 6 #define CHROME_BROWSER_FAVICON_FAVICON_SERVICE_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 GURL page_url; | 49 GURL page_url; |
50 int icon_types; | 50 int icon_types; |
51 int desired_size_in_dip; | 51 int desired_size_in_dip; |
52 CancelableRequestConsumerBase* consumer; | 52 CancelableRequestConsumerBase* consumer; |
53 }; | 53 }; |
54 | 54 |
55 // Callback for GetFaviconImage() and GetFaviconImageForURL(). | 55 // Callback for GetFaviconImage() and GetFaviconImageForURL(). |
56 // |FaviconImageResult::image| is constructed from the bitmaps for the | 56 // |FaviconImageResult::image| is constructed from the bitmaps for the |
57 // passed in URL and icon types which most which closely match the passed in | 57 // passed in URL and icon types which most which closely match the passed in |
58 // |desired_size_in_dip| at the scale factors supported by the current | 58 // |desired_size_in_dip| at the scale factors supported by the current |
59 // platform (eg MacOS) in addition to 1x. | 59 // platform (eg MacOS). |
60 // |FaviconImageResult::icon_url| is the favicon that the favicon bitmaps in | 60 // |FaviconImageResult::icon_url| is the favicon that the favicon bitmaps in |
61 // |image| originate from. | 61 // |image| originate from. |
62 // TODO(pkotwicz): Enable constructing |image| from bitmaps from several | 62 // TODO(pkotwicz): Enable constructing |image| from bitmaps from several |
63 // icon URLs. | 63 // icon URLs. |
64 typedef base::Callback<void(Handle, const history::FaviconImageResult&)> | 64 typedef base::Callback<void(Handle, const history::FaviconImageResult&)> |
65 FaviconImageCallback; | 65 FaviconImageCallback; |
66 | 66 |
67 // Callback for GetRawFavicon() and GetRawFaviconForURL(). | 67 // Callback for GetRawFavicon() and GetRawFaviconForURL(). |
68 // FaviconBitmapResult::bitmap_data is the bitmap in the thumbnail database | 68 // FaviconBitmapResult::bitmap_data is the bitmap in the thumbnail database |
69 // for the passed in URL and icon types whose pixel size best matches the | 69 // for the passed in URL and icon types whose pixel size best matches the |
70 // passed in |desired_size_in_dip| and |desired_scale_factor|. Returns an | 70 // passed in |desired_size_in_dip| and |desired_scale_factor|. Returns an |
71 // invalid history::FaviconBitmapResult if there are no matches. | 71 // invalid history::FaviconBitmapResult if there are no matches. |
72 typedef base::Callback<void(Handle, const history::FaviconBitmapResult&)> | 72 typedef base::Callback<void(Handle, const history::FaviconBitmapResult&)> |
73 FaviconRawCallback; | 73 FaviconRawCallback; |
74 | 74 |
75 // Callback for GetFavicon() and GetFaviconForURL(). | 75 // Callback for GetFavicon() and GetFaviconForURL(). |
76 // | 76 // |
77 // The second argument is the set of bitmaps for the passed in URL and | 77 // The second argument is the set of bitmaps for the passed in URL and |
78 // icon types whose pixel sizes best match the passed in | 78 // icon types whose pixel sizes best match the passed in |
79 // |desired_size_in_dip| at the scale factors supported by the current | 79 // |desired_size_in_dip| and |desired_scale_factors|. The vector has at most |
80 // platform (eg MacOS) in addition to 1x. The vector has at most one result | 80 // one result for each of |desired_scale_factors|. There are less entries if |
81 // for each of the scale factors. There are less entries if a single result | 81 // a single result is the best bitmap to use for several scale factors. |
82 // is the best bitmap to use for several scale factors. | |
83 // | 82 // |
84 // Third argument: | 83 // Third argument: |
85 // a) If the callback is called as a result of GetFaviconForURL(): | 84 // a) If the callback is called as a result of GetFaviconForURL(): |
86 // The third argument is a map of the icon URLs mapped to |page_url| to | 85 // The third argument is a map of the icon URLs mapped to |page_url| to |
87 // the sizes at which the favicon is available from the web. | 86 // the sizes at which the favicon is available from the web. |
88 // b) If the callback is called as a result of GetFavicon() or | 87 // b) If the callback is called as a result of GetFavicon() or |
89 // UpdateFaviconMappingsAndFetch(): | 88 // UpdateFaviconMappingsAndFetch(): |
90 // The third argument is a map of the subset of |icon_urls| known to the | 89 // The third argument is a map of the subset of |icon_urls| known to the |
91 // history backend to a vector of sizes of the favicon bitmaps at each | 90 // history backend to a vector of sizes of the favicon bitmaps at each |
92 // URL. If none of |icon_urls| are known to the history backend, an empty | 91 // URL. If none of |icon_urls| are known to the history backend, an empty |
(...skipping 24 matching lines...) Expand all Loading... |
117 Handle GetRawFavicon(const GURL& icon_url, | 116 Handle GetRawFavicon(const GURL& icon_url, |
118 history::IconType icon_type, | 117 history::IconType icon_type, |
119 int desired_size_in_dip, | 118 int desired_size_in_dip, |
120 ui::ScaleFactor desired_scale_factor, | 119 ui::ScaleFactor desired_scale_factor, |
121 CancelableRequestConsumerBase* consumer, | 120 CancelableRequestConsumerBase* consumer, |
122 const FaviconRawCallback& callback); | 121 const FaviconRawCallback& callback); |
123 | 122 |
124 Handle GetFavicon(const GURL& icon_url, | 123 Handle GetFavicon(const GURL& icon_url, |
125 history::IconType icon_type, | 124 history::IconType icon_type, |
126 int desired_size_in_dip, | 125 int desired_size_in_dip, |
| 126 const std::vector<ui::ScaleFactor>& desired_scale_factors, |
127 CancelableRequestConsumerBase* consumer, | 127 CancelableRequestConsumerBase* consumer, |
128 const FaviconResultsCallback& callback); | 128 const FaviconResultsCallback& callback); |
129 | 129 |
130 // Set the favicon mappings to |page_url| for |icon_types| in the history | 130 // Set the favicon mappings to |page_url| for |icon_types| in the history |
131 // database. | 131 // database. |
132 // Sample |icon_urls|: | 132 // Sample |icon_urls|: |
133 // { ICON_URL1 -> TOUCH_ICON, known to the database, | 133 // { ICON_URL1 -> TOUCH_ICON, known to the database, |
134 // ICON_URL2 -> TOUCH_ICON, not known to the database, | 134 // ICON_URL2 -> TOUCH_ICON, not known to the database, |
135 // ICON_URL3 -> TOUCH_PRECOMPOSED_ICON, known to the database } | 135 // ICON_URL3 -> TOUCH_PRECOMPOSED_ICON, known to the database } |
136 // The new mappings are computed from |icon_urls| with these rules: | 136 // The new mappings are computed from |icon_urls| with these rules: |
137 // 1) Any urls in |icon_urls| which are not already known to the database are | 137 // 1) Any urls in |icon_urls| which are not already known to the database are |
138 // rejected. | 138 // rejected. |
139 // Sample new mappings to |page_url|: { ICON_URL1, ICON_URL3 } | 139 // Sample new mappings to |page_url|: { ICON_URL1, ICON_URL3 } |
140 // 2) If |icon_types| has multiple types, the mappings are only set for the | 140 // 2) If |icon_types| has multiple types, the mappings are only set for the |
141 // largest icon type. | 141 // largest icon type. |
142 // Sample new mappings to |page_url|: { ICON_URL3 } | 142 // Sample new mappings to |page_url|: { ICON_URL3 } |
143 // |icon_types| can only have multiple IconTypes if | 143 // |icon_types| can only have multiple IconTypes if |
144 // |icon_types| == TOUCH_ICON | TOUCH_PRECOMPOSED_ICON. | 144 // |icon_types| == TOUCH_ICON | TOUCH_PRECOMPOSED_ICON. |
145 // The favicon bitmaps which most closely match |desired_size_in_dip| | 145 // The favicon bitmaps which most closely match |desired_size_in_dip| |
146 // at the scale factors supported by the current platform (eg MacOS) in | 146 // and |desired_scale_factors| from the favicons which were just mapped |
147 // addition to 1x from the favicons which were just mapped to |page_url| are | 147 // to |page_url| are returned. If |desired_size_in_dip| is 0, the |
148 // returned. If |desired_size_in_dip| is 0, the largest favicon bitmap is | 148 // largest favicon bitmap is returned. |
149 // returned. | |
150 Handle UpdateFaviconMappingsAndFetch( | 149 Handle UpdateFaviconMappingsAndFetch( |
151 const GURL& page_url, | 150 const GURL& page_url, |
152 const std::vector<GURL>& icon_urls, | 151 const std::vector<GURL>& icon_urls, |
153 int icon_types, | 152 int icon_types, |
154 int desired_size_in_dip, | 153 int desired_size_in_dip, |
| 154 const std::vector<ui::ScaleFactor>& desired_scale_factors, |
155 CancelableRequestConsumerBase* consumer, | 155 CancelableRequestConsumerBase* consumer, |
156 const FaviconResultsCallback& callback); | 156 const FaviconResultsCallback& callback); |
157 | 157 |
158 // Requests the favicons of any of |icon_types| whose pixel sizes most | 158 // Requests the favicons of any of |icon_types| whose pixel sizes most |
159 // closely match |desired_size_in_dip| and desired scale factors for a web | 159 // closely match |desired_size_in_dip| and desired scale factors for a web |
160 // page URL. If |desired_size_in_dip| is 0, the largest favicon for the web | 160 // page URL. If |desired_size_in_dip| is 0, the largest favicon for the web |
161 // page URL is returned. |consumer| is notified when the bits have been | 161 // page URL is returned. |consumer| is notified when the bits have been |
162 // fetched. |icon_types| can be any combination of IconType value, but only | 162 // fetched. |icon_types| can be any combination of IconType value, but only |
163 // one icon will be returned in the priority of TOUCH_PRECOMPOSED_ICON, | 163 // one icon will be returned in the priority of TOUCH_PRECOMPOSED_ICON, |
164 // TOUCH_ICON and FAVICON. Each of the three methods below differs in the | 164 // TOUCH_ICON and FAVICON. Each of the three methods below differs in the |
165 // format of the callback and the requested scale factors. All of the scale | 165 // format of the callback and the requested scale factors. All of the scale |
166 // factors supported by the current platform (eg MacOS) are requested for | 166 // factors supported by the current platform (eg MacOS) are requested for |
167 // GetFaviconImageForURL(). | 167 // GetFaviconImageForURL(). |
168 Handle GetFaviconImageForURL(const FaviconForURLParams& params, | 168 Handle GetFaviconImageForURL(const FaviconForURLParams& params, |
169 const FaviconImageCallback& callback); | 169 const FaviconImageCallback& callback); |
170 | 170 |
171 Handle GetRawFaviconForURL(const FaviconForURLParams& params, | 171 Handle GetRawFaviconForURL(const FaviconForURLParams& params, |
172 ui::ScaleFactor desired_scale_factor, | 172 ui::ScaleFactor desired_scale_factor, |
173 const FaviconRawCallback& callback); | 173 const FaviconRawCallback& callback); |
174 | 174 |
175 Handle GetFaviconForURL( | 175 Handle GetFaviconForURL( |
176 const FaviconForURLParams& params, | 176 const FaviconForURLParams& params, |
| 177 const std::vector<ui::ScaleFactor>& desired_scale_factors, |
177 const FaviconResultsCallback& callback); | 178 const FaviconResultsCallback& callback); |
178 | 179 |
179 // Used to request a bitmap for the favicon with |favicon_id| which is not | 180 // Used to request a bitmap for the favicon with |favicon_id| which is not |
180 // resized from the size it is stored at in the database. If there are | 181 // resized from the size it is stored at in the database. If there are |
181 // multiple favicon bitmaps for |favicon_id|, the largest favicon bitmap is | 182 // multiple favicon bitmaps for |favicon_id|, the largest favicon bitmap is |
182 // returned. | 183 // returned. |
183 Handle GetLargestRawFaviconForID(history::FaviconID favicon_id, | 184 Handle GetLargestRawFaviconForID(history::FaviconID favicon_id, |
184 CancelableRequestConsumerBase* consumer, | 185 CancelableRequestConsumerBase* consumer, |
185 const FaviconRawCallback& callback); | 186 const FaviconRawCallback& callback); |
186 | 187 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 ui::ScaleFactor desired_scale_factor, | 264 ui::ScaleFactor desired_scale_factor, |
264 FaviconRawCallback callback, | 265 FaviconRawCallback callback, |
265 Handle handle, | 266 Handle handle, |
266 std::vector<history::FaviconBitmapResult> favicon_bitmap_results, | 267 std::vector<history::FaviconBitmapResult> favicon_bitmap_results, |
267 history::IconURLSizesMap icon_url_sizes_map); | 268 history::IconURLSizesMap icon_url_sizes_map); |
268 | 269 |
269 DISALLOW_COPY_AND_ASSIGN(FaviconService); | 270 DISALLOW_COPY_AND_ASSIGN(FaviconService); |
270 }; | 271 }; |
271 | 272 |
272 #endif // CHROME_BROWSER_FAVICON_FAVICON_SERVICE_H_ | 273 #endif // CHROME_BROWSER_FAVICON_FAVICON_SERVICE_H_ |
OLD | NEW |