| 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 <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 FaviconHandler(FaviconService* service, | 132 FaviconHandler(FaviconService* service, |
| 133 Delegate* delegate, | 133 Delegate* delegate, |
| 134 FaviconDriverObserver::NotificationIconType handler_type); | 134 FaviconDriverObserver::NotificationIconType handler_type); |
| 135 ~FaviconHandler(); | 135 ~FaviconHandler(); |
| 136 | 136 |
| 137 // Initiates loading the favicon for the specified url. | 137 // Initiates loading the favicon for the specified url. |
| 138 void FetchFavicon(const GURL& url); | 138 void FetchFavicon(const GURL& url); |
| 139 | 139 |
| 140 // Message Handler. Must be public, because also called from | 140 // Message Handler. Must be public, because also called from |
| 141 // PrerenderContents. Collects the |image_urls| list. | 141 // PrerenderContents. Collects the |image_urls| list. |
| 142 void OnUpdateFaviconURL(const GURL& page_url, | 142 void OnUpdateCandidates(const GURL& page_url, |
| 143 const std::vector<favicon::FaviconURL>& candidates); | 143 const std::vector<favicon::FaviconURL>& candidates); |
| 144 | 144 |
| 145 // For testing. | 145 // For testing. |
| 146 const std::vector<GURL> GetIconURLs() const; | 146 const std::vector<GURL> GetIconURLs() const; |
| 147 | 147 |
| 148 // Returns whether the handler is waiting for a download to complete or for | 148 // Returns whether the handler is waiting for a download to complete or for |
| 149 // data from the FaviconService. Reserved for testing. | 149 // data from the FaviconService. Reserved for testing. |
| 150 bool HasPendingTasksForTest(); | 150 bool HasPendingTasksForTest(); |
| 151 | 151 |
| 152 // Get the maximal icon size in pixels for a handler of type |handler_type|. | 152 // Get the maximal icon size in pixels for a handler of type |handler_type|. |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 // current candidate favicon from the renderer. Otherwise requests data for | 199 // current candidate favicon from the renderer. Otherwise requests data for |
| 200 // the current favicon from history. If data is requested from history, | 200 // the current favicon from history. If data is requested from history, |
| 201 // OnFaviconData() is called with the history data once it has been retrieved. | 201 // OnFaviconData() is called with the history data once it has been retrieved. |
| 202 void DownloadCurrentCandidateOrAskFaviconService(); | 202 void DownloadCurrentCandidateOrAskFaviconService(); |
| 203 | 203 |
| 204 // See description above class for details. | 204 // See description above class for details. |
| 205 void OnFaviconData(const std::vector<favicon_base::FaviconRawBitmapResult>& | 205 void OnFaviconData(const std::vector<favicon_base::FaviconRawBitmapResult>& |
| 206 favicon_bitmap_results); | 206 favicon_bitmap_results); |
| 207 | 207 |
| 208 // Schedules a download for the specified entry. This adds the request to | 208 // Schedules a download for the specified entry. This adds the request to |
| 209 // download_requests_. | 209 // image_download_requests_. |
| 210 void ScheduleDownload(const GURL& image_url, | 210 void ScheduleImageDownload(const GURL& image_url, |
| 211 favicon_base::IconType icon_type); | 211 favicon_base::IconType icon_type); |
| 212 | 212 |
| 213 // Triggered when a download of an image has finished. | 213 // Triggered when a download of an image has finished. |
| 214 void OnDidDownloadFavicon( | 214 void OnDidDownloadFavicon( |
| 215 favicon_base::IconType icon_type, | 215 favicon_base::IconType icon_type, |
| 216 int id, | 216 int id, |
| 217 int http_status_code, | 217 int http_status_code, |
| 218 const GURL& image_url, | 218 const GURL& image_url, |
| 219 const std::vector<SkBitmap>& bitmaps, | 219 const std::vector<SkBitmap>& bitmaps, |
| 220 const std::vector<gfx::Size>& original_bitmap_sizes); | 220 const std::vector<gfx::Size>& original_bitmap_sizes); |
| 221 | 221 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 // database has expired or the data in the database is incomplete. | 278 // database has expired or the data in the database is incomplete. |
| 279 bool initial_history_result_expired_or_incomplete_; | 279 bool initial_history_result_expired_or_incomplete_; |
| 280 | 280 |
| 281 // Whether FaviconHandler should ignore history state and determine the | 281 // Whether FaviconHandler should ignore history state and determine the |
| 282 // optimal icon URL out of |image_urls_| for |url_| by downloading | 282 // optimal icon URL out of |image_urls_| for |url_| by downloading |
| 283 // |image_urls_| one by one. | 283 // |image_urls_| one by one. |
| 284 bool redownload_icons_; | 284 bool redownload_icons_; |
| 285 | 285 |
| 286 // Requests to the renderer to download favicons. | 286 // Requests to the renderer to download favicons. |
| 287 base::CancelableCallback<Delegate::ImageDownloadCallback::RunType> | 287 base::CancelableCallback<Delegate::ImageDownloadCallback::RunType> |
| 288 download_request_; | 288 image_download_request_; |
| 289 | 289 |
| 290 // The combination of the supported icon types. | 290 // The combination of the supported icon types. |
| 291 const int icon_types_; | 291 const int icon_types_; |
| 292 | 292 |
| 293 // Whether the largest icon should be downloaded. | 293 // Whether the largest icon should be downloaded. |
| 294 const bool download_largest_icon_; | 294 const bool download_largest_icon_; |
| 295 | 295 |
| 296 // The prioritized favicon candidates from the page back from the renderer. | 296 // The prioritized favicon candidates from the page back from the renderer. |
| 297 std::vector<FaviconCandidate> candidates_; | 297 std::vector<FaviconCandidate> candidates_; |
| 298 | 298 |
| 299 // The icon URL and the icon type of the favicon in the most recent | 299 // The icon URL and the icon type of the favicon in the most recent |
| 300 // FaviconDriver::OnFaviconAvailable() notification. | 300 // FaviconDriver::OnFaviconAvailable() notification. |
| 301 GURL notification_icon_url_; | 301 GURL notification_icon_url_; |
| 302 favicon_base::IconType notification_icon_type_; | 302 favicon_base::IconType notification_icon_type_; |
| 303 | 303 |
| 304 // The FaviconService which implements favicon operations. May be null during | 304 // The FaviconService which implements favicon operations. May be null during |
| 305 // testing. | 305 // testing. |
| 306 FaviconService* service_; | 306 FaviconService* service_; |
| 307 | 307 |
| 308 // This handler's delegate. | 308 // This handler's delegate. |
| 309 Delegate* delegate_; | 309 Delegate* delegate_; |
| 310 | 310 |
| 311 // Captures the number of download requests that were initiated for the | 311 // Captures the number of download requests that were initiated for the |
| 312 // current url_. | 312 // current url_. |
| 313 int num_download_requests_; | 313 int num_image_download_requests_; |
| 314 | 314 |
| 315 // The index of the favicon URL in |image_urls_| which is currently being | 315 // The index of the favicon URL in |image_urls_| which is currently being |
| 316 // requested from history or downloaded. | 316 // requested from history or downloaded. |
| 317 size_t current_candidate_index_; | 317 size_t current_candidate_index_; |
| 318 | 318 |
| 319 // Best image we've seen so far. As images are downloaded from the page they | 319 // Best image we've seen so far. As images are downloaded from the page they |
| 320 // are stored here. When a satisfying icon is found (as defined in | 320 // are stored here. When a satisfying icon is found (as defined in |
| 321 // UpdateFaviconCandidate()), the favicon service and the delegate are | 321 // UpdateFaviconCandidate()), the favicon service and the delegate are |
| 322 // notified. | 322 // notified. |
| 323 DownloadedFavicon best_favicon_; | 323 DownloadedFavicon best_favicon_; |
| 324 | 324 |
| 325 DISALLOW_COPY_AND_ASSIGN(FaviconHandler); | 325 DISALLOW_COPY_AND_ASSIGN(FaviconHandler); |
| 326 }; | 326 }; |
| 327 | 327 |
| 328 } // namespace favicon | 328 } // namespace favicon |
| 329 | 329 |
| 330 #endif // COMPONENTS_FAVICON_CORE_FAVICON_HANDLER_H_ | 330 #endif // COMPONENTS_FAVICON_CORE_FAVICON_HANDLER_H_ |
| OLD | NEW |