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 COMPONENTS_FAVICON_CORE_FAVICON_HANDLER_H_ | 5 #ifndef COMPONENTS_FAVICON_CORE_FAVICON_HANDLER_H_ |
6 #define COMPONENTS_FAVICON_CORE_FAVICON_HANDLER_H_ | 6 #define COMPONENTS_FAVICON_CORE_FAVICON_HANDLER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 void DownloadFaviconOrAskFaviconService(const GURL& page_url, | 205 void DownloadFaviconOrAskFaviconService(const GURL& page_url, |
206 const GURL& icon_url, | 206 const GURL& icon_url, |
207 favicon_base::IconType icon_type); | 207 favicon_base::IconType icon_type); |
208 | 208 |
209 // See description above class for details. | 209 // See description above class for details. |
210 void OnFaviconData(const std::vector<favicon_base::FaviconRawBitmapResult>& | 210 void OnFaviconData(const std::vector<favicon_base::FaviconRawBitmapResult>& |
211 favicon_bitmap_results); | 211 favicon_bitmap_results); |
212 | 212 |
213 // Schedules a download for the specified entry. This adds the request to | 213 // Schedules a download for the specified entry. This adds the request to |
214 // download_requests_. | 214 // download_requests_. |
215 int ScheduleDownload(const GURL& url, | 215 void ScheduleDownload(const GURL& url, |
216 const GURL& image_url, | 216 const GURL& image_url, |
217 favicon_base::IconType icon_type); | 217 favicon_base::IconType icon_type); |
218 | 218 |
219 // Updates |favicon_candidate_| and returns true if it is an exact match. | 219 // Updates |favicon_candidate_| and returns true if it is an exact match. |
220 bool UpdateFaviconCandidate(const GURL& url, | 220 bool UpdateFaviconCandidate(const GURL& url, |
221 const GURL& image_url, | 221 const GURL& image_url, |
222 const gfx::Image& image, | 222 const gfx::Image& image, |
223 float score, | 223 float score, |
224 favicon_base::IconType icon_type); | 224 favicon_base::IconType icon_type); |
225 | 225 |
226 // Sets the image data for the favicon. | 226 // Sets the image data for the favicon. |
227 void SetFavicon(const GURL& url, | 227 void SetFavicon(const GURL& url, |
228 const GURL& icon_url, | 228 const GURL& icon_url, |
229 const gfx::Image& image, | 229 const gfx::Image& image, |
230 favicon_base::IconType icon_type); | 230 favicon_base::IconType icon_type); |
231 | 231 |
232 // Notifies |driver_| favicon available. See | 232 // Notifies |driver_| favicon available. See |
233 // FaviconDriver::NotifyFaviconAvailable() for |is_active_favicon| in detail. | 233 // FaviconDriver::NotifyFaviconAvailable() for |is_active_favicon| in detail. |
234 void NotifyFaviconAvailable( | 234 void NotifyFaviconAvailable( |
235 const std::vector<favicon_base::FaviconRawBitmapResult>& | 235 const std::vector<favicon_base::FaviconRawBitmapResult>& |
236 favicon_bitmap_results, | 236 favicon_bitmap_results); |
237 bool is_active_favicon); | |
238 void NotifyFaviconAvailable(const GURL& icon_url, | 237 void NotifyFaviconAvailable(const GURL& icon_url, |
239 const gfx::Image& image, | 238 const gfx::Image& image); |
240 bool is_active_favicon); | |
241 | 239 |
242 // Return the current candidate if any. | 240 // Return the current candidate if any. |
243 favicon::FaviconURL* current_candidate() { | 241 favicon::FaviconURL* current_candidate() { |
244 return (!image_urls_.empty()) ? &image_urls_.front() : NULL; | 242 return (!image_urls_.empty()) ? &image_urls_.front() : NULL; |
245 } | 243 } |
246 | 244 |
247 // Returns whether the page's url changed since the favicon was requested. | 245 // Returns whether the page's url changed since the favicon was requested. |
248 bool PageChangedSinceFaviconWasRequested(); | 246 bool PageChangedSinceFaviconWasRequested(); |
249 | 247 |
250 // Returns the preferred size of the image. 0 means no preference (any size | 248 // Returns the preferred size of the image. 0 means no preference (any size |
251 // will do). | 249 // will do). |
252 int preferred_icon_size() const { | 250 int preferred_icon_size() const { |
253 if (download_largest_icon_) | 251 if (download_largest_icon_) |
254 return 0; | 252 return 0; |
255 return handler_type_ == FAVICON ? gfx::kFaviconSize : 0; | 253 return handler_type_ == FAVICON ? gfx::kFaviconSize : 0; |
256 } | 254 } |
257 | 255 |
258 // Sorts the entries in |image_urls_| by icon size in descending order. | 256 // Sorts the entries in |image_urls_| by icon size in descending order. |
259 // Additionally removes any entries whose sizes are all greater than the max | 257 // Additionally removes any entries whose sizes are all greater than the max |
260 // allowed size. | 258 // allowed size. |
261 void SortAndPruneImageUrls(); | 259 void SortAndPruneImageUrls(); |
262 | 260 |
263 // Used for FaviconService requests. | 261 // Used for FaviconService requests. |
264 base::CancelableTaskTracker cancelable_task_tracker_; | 262 base::CancelableTaskTracker cancelable_task_tracker_; |
265 | 263 |
266 // URL of the page we're requesting the favicon for. | 264 // URL of the page we're requesting the favicon for. |
267 GURL url_; | 265 GURL url_; |
268 | 266 |
269 // Whether we are waiting for data from the FaviconService. | |
270 bool waiting_for_favicon_service_data_; | |
271 | |
272 // Whether we got data back for the initial request to the FaviconService. | 267 // Whether we got data back for the initial request to the FaviconService. |
273 bool got_favicon_from_history_; | 268 bool got_favicon_from_history_; |
274 | 269 |
275 // Whether the favicon is out of date or the favicon data in | 270 // Whether the favicon is out of date or the favicon data in |
276 // |history_results_| is known to be incomplete. If true, it means history | 271 // |history_results_| is known to be incomplete. If true, it means history |
277 // knows about the favicon, but we need to download the favicon because the | 272 // knows about the favicon, but we need to download the favicon because the |
278 // icon has expired or the data in the database is incomplete. | 273 // icon has expired or the data in the database is incomplete. |
279 bool favicon_expired_or_incomplete_; | 274 bool favicon_expired_or_incomplete_; |
280 | 275 |
281 // Requests to the renderer to download favicons. | 276 // Requests to the renderer to download favicons. |
(...skipping 27 matching lines...) Expand all Loading... |
309 // available the favicon service and the current page are updated (assuming | 304 // available the favicon service and the current page are updated (assuming |
310 // the image is for a favicon). | 305 // the image is for a favicon). |
311 FaviconCandidate best_favicon_candidate_; | 306 FaviconCandidate best_favicon_candidate_; |
312 | 307 |
313 DISALLOW_COPY_AND_ASSIGN(FaviconHandler); | 308 DISALLOW_COPY_AND_ASSIGN(FaviconHandler); |
314 }; | 309 }; |
315 | 310 |
316 } // namespace favicon | 311 } // namespace favicon |
317 | 312 |
318 #endif // COMPONENTS_FAVICON_CORE_FAVICON_HANDLER_H_ | 313 #endif // COMPONENTS_FAVICON_CORE_FAVICON_HANDLER_H_ |
OLD | NEW |