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_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_FAVICON_FAVICON_HANDLER_H_ |
6 #define CHROME_BROWSER_FAVICON_FAVICON_HANDLER_H_ | 6 #define CHROME_BROWSER_FAVICON_FAVICON_HANDLER_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <map> | 9 #include <map> |
10 #include <vector> | 10 #include <vector> |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 | 184 |
185 GURL url; | 185 GURL url; |
186 GURL image_url; | 186 GURL image_url; |
187 gfx::Image image; | 187 gfx::Image image; |
188 float score; | 188 float score; |
189 favicon_base::IconType icon_type; | 189 favicon_base::IconType icon_type; |
190 }; | 190 }; |
191 | 191 |
192 // See description above class for details. | 192 // See description above class for details. |
193 void OnFaviconDataForInitialURLFromFaviconService(const std::vector< | 193 void OnFaviconDataForInitialURLFromFaviconService(const std::vector< |
194 favicon_base::FaviconBitmapResult>& favicon_bitmap_results); | 194 favicon_base::FaviconRawBitmapResult>& favicon_bitmap_results); |
195 | 195 |
196 // If the favicon has expired, asks the renderer to download the favicon. | 196 // If the favicon has expired, asks the renderer to download the favicon. |
197 // Otherwise asks history to update the mapping between page url and icon | 197 // Otherwise asks history to update the mapping between page url and icon |
198 // url with a callback to OnFaviconData when done. | 198 // url with a callback to OnFaviconData when done. |
199 void DownloadFaviconOrAskFaviconService(const GURL& page_url, | 199 void DownloadFaviconOrAskFaviconService(const GURL& page_url, |
200 const GURL& icon_url, | 200 const GURL& icon_url, |
201 favicon_base::IconType icon_type); | 201 favicon_base::IconType icon_type); |
202 | 202 |
203 // See description above class for details. | 203 // See description above class for details. |
204 void OnFaviconData(const std::vector<favicon_base::FaviconBitmapResult>& | 204 void OnFaviconData(const std::vector<favicon_base::FaviconRawBitmapResult>& |
205 favicon_bitmap_results); | 205 favicon_bitmap_results); |
206 | 206 |
207 // Schedules a download for the specified entry. This adds the request to | 207 // Schedules a download for the specified entry. This adds the request to |
208 // download_requests_. | 208 // download_requests_. |
209 int ScheduleDownload(const GURL& url, | 209 int ScheduleDownload(const GURL& url, |
210 const GURL& image_url, | 210 const GURL& image_url, |
211 favicon_base::IconType icon_type); | 211 favicon_base::IconType icon_type); |
212 | 212 |
213 // Updates |favicon_candidate_| and returns true if it is an exact match. | 213 // Updates |favicon_candidate_| and returns true if it is an exact match. |
214 bool UpdateFaviconCandidate(const GURL& url, | 214 bool UpdateFaviconCandidate(const GURL& url, |
215 const GURL& image_url, | 215 const GURL& image_url, |
216 const gfx::Image& image, | 216 const gfx::Image& image, |
217 float score, | 217 float score, |
218 favicon_base::IconType icon_type); | 218 favicon_base::IconType icon_type); |
219 | 219 |
220 // Sets the image data for the favicon. | 220 // Sets the image data for the favicon. |
221 void SetFavicon(const GURL& url, | 221 void SetFavicon(const GURL& url, |
222 const GURL& icon_url, | 222 const GURL& icon_url, |
223 const gfx::Image& image, | 223 const gfx::Image& image, |
224 favicon_base::IconType icon_type); | 224 favicon_base::IconType icon_type); |
225 | 225 |
226 // Sets the favicon's data. | 226 // Sets the favicon's data. |
227 void SetFaviconOnActivePage(const std::vector< | 227 void SetFaviconOnActivePage(const std::vector< |
228 favicon_base::FaviconBitmapResult>& favicon_bitmap_results); | 228 favicon_base::FaviconRawBitmapResult>& favicon_bitmap_results); |
229 void SetFaviconOnActivePage(const GURL& icon_url, const gfx::Image& image); | 229 void SetFaviconOnActivePage(const GURL& icon_url, const gfx::Image& image); |
230 | 230 |
231 // Return the current candidate if any. | 231 // Return the current candidate if any. |
232 favicon::FaviconURL* current_candidate() { | 232 favicon::FaviconURL* current_candidate() { |
233 return (!image_urls_.empty()) ? &image_urls_.front() : NULL; | 233 return (!image_urls_.empty()) ? &image_urls_.front() : NULL; |
234 } | 234 } |
235 | 235 |
236 // Returns whether the page's url changed since the favicon was requested. | 236 // Returns whether the page's url changed since the favicon was requested. |
237 bool PageChangedSinceFaviconWasRequested(); | 237 bool PageChangedSinceFaviconWasRequested(); |
238 | 238 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 | 270 |
271 // The combination of the supported icon types. | 271 // The combination of the supported icon types. |
272 const int icon_types_; | 272 const int icon_types_; |
273 | 273 |
274 // Whether the largest icon should be downloaded. | 274 // Whether the largest icon should be downloaded. |
275 const bool download_largest_icon_; | 275 const bool download_largest_icon_; |
276 | 276 |
277 // The prioritized favicon candidates from the page back from the renderer. | 277 // The prioritized favicon candidates from the page back from the renderer. |
278 std::vector<favicon::FaviconURL> image_urls_; | 278 std::vector<favicon::FaviconURL> image_urls_; |
279 | 279 |
280 // The FaviconBitmapResults from history. | 280 // The FaviconRawBitmapResults from history. |
281 std::vector<favicon_base::FaviconBitmapResult> history_results_; | 281 std::vector<favicon_base::FaviconRawBitmapResult> history_results_; |
282 | 282 |
283 // The client which implements embedder-specific Favicon operations. | 283 // The client which implements embedder-specific Favicon operations. |
284 FaviconClient* client_; // weak | 284 FaviconClient* client_; // weak |
285 | 285 |
286 // This handler's driver. | 286 // This handler's driver. |
287 FaviconDriver* driver_; // weak | 287 FaviconDriver* driver_; // weak |
288 | 288 |
289 // Best image we've seen so far. As images are downloaded from the page they | 289 // Best image we've seen so far. As images are downloaded from the page they |
290 // are stored here. When there is an exact match, or no more images are | 290 // are stored here. When there is an exact match, or no more images are |
291 // available the favicon service and the current page are updated (assuming | 291 // available the favicon service and the current page are updated (assuming |
292 // the image is for a favicon). | 292 // the image is for a favicon). |
293 FaviconCandidate best_favicon_candidate_; | 293 FaviconCandidate best_favicon_candidate_; |
294 | 294 |
295 DISALLOW_COPY_AND_ASSIGN(FaviconHandler); | 295 DISALLOW_COPY_AND_ASSIGN(FaviconHandler); |
296 }; | 296 }; |
297 | 297 |
298 #endif // CHROME_BROWSER_FAVICON_FAVICON_HANDLER_H_ | 298 #endif // CHROME_BROWSER_FAVICON_FAVICON_HANDLER_H_ |
OLD | NEW |