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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 static int GetIconTypesFromHandlerType(Type icon_type); | 90 static int GetIconTypesFromHandlerType(Type icon_type); |
91 | 91 |
92 // Initiates loading the favicon for the specified url. | 92 // Initiates loading the favicon for the specified url. |
93 void FetchFavicon(const GURL& url); | 93 void FetchFavicon(const GURL& url); |
94 | 94 |
95 // Message Handler. Must be public, because also called from | 95 // Message Handler. Must be public, because also called from |
96 // PrerenderContents. Collects the |image_urls| list. | 96 // PrerenderContents. Collects the |image_urls| list. |
97 void OnUpdateFaviconURL(const GURL& page_url, | 97 void OnUpdateFaviconURL(const GURL& page_url, |
98 const std::vector<favicon::FaviconURL>& candidates); | 98 const std::vector<favicon::FaviconURL>& candidates); |
99 | 99 |
100 // Processes the current image_urls_ entry, requesting the image from the | 100 // Called when the history request for favicon data mapped to |url_| has |
101 // history / download service. | 101 // completed and the renderer has told us the icon URLs used by |url_| |
102 void ProcessCurrentUrl(); | 102 void OnGotInitialHistoryDataAndIconURLCandidates(); |
103 | 103 |
104 // Message handler for ImageHostMsg_DidDownloadImage. Called when the image | 104 // Message handler for ImageHostMsg_DidDownloadImage. Called when the image |
105 // at |image_url| has been downloaded. | 105 // at |image_url| has been downloaded. |
106 // |bitmaps| is a list of all the frames of the image at |image_url|. | 106 // |bitmaps| is a list of all the frames of the image at |image_url|. |
107 // |original_bitmap_sizes| are the sizes of |bitmaps| before they were resized | 107 // |original_bitmap_sizes| are the sizes of |bitmaps| before they were resized |
108 // to the maximum bitmap size passed to DownloadFavicon(). | 108 // to the maximum bitmap size passed to DownloadFavicon(). |
109 void OnDidDownloadFavicon( | 109 void OnDidDownloadFavicon( |
110 int id, | 110 int id, |
111 const GURL& image_url, | 111 const GURL& image_url, |
112 const std::vector<SkBitmap>& bitmaps, | 112 const std::vector<SkBitmap>& bitmaps, |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 }; | 188 }; |
189 | 189 |
190 // Get the maximal icon size in pixels for a icon of type |icon_type| for the | 190 // Get the maximal icon size in pixels for a icon of type |icon_type| for the |
191 // current platform. | 191 // current platform. |
192 static int GetMaximalIconSize(favicon_base::IconType icon_type); | 192 static int GetMaximalIconSize(favicon_base::IconType icon_type); |
193 | 193 |
194 // See description above class for details. | 194 // See description above class for details. |
195 void OnFaviconDataForInitialURLFromFaviconService(const std::vector< | 195 void OnFaviconDataForInitialURLFromFaviconService(const std::vector< |
196 favicon_base::FaviconRawBitmapResult>& favicon_bitmap_results); | 196 favicon_base::FaviconRawBitmapResult>& favicon_bitmap_results); |
197 | 197 |
198 // If the favicon has expired, asks the renderer to download the favicon. | 198 // If the favicon currently mapped to |url_| has expired, downloads the |
199 // Otherwise asks history to update the mapping between page url and icon | 199 // current candidate favicon from the renderer. Otherwise requests data for |
200 // url with a callback to OnFaviconData when done. | 200 // the current favicon from history. If data is requested from history, |
201 void DownloadFaviconOrAskFaviconService(const GURL& icon_url, | 201 // OnFaviconData() is called with the history data once it has been retrieved. |
202 favicon_base::IconType icon_type); | 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 // download_requests_. |
210 void ScheduleDownload(const GURL& image_url, | 210 void ScheduleDownload(const GURL& image_url, |
211 favicon_base::IconType icon_type); | 211 favicon_base::IconType icon_type); |
212 | 212 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 // available the favicon service and the current page are updated (assuming | 294 // available the favicon service and the current page are updated (assuming |
295 // the image is for a favicon). | 295 // the image is for a favicon). |
296 FaviconCandidate best_favicon_candidate_; | 296 FaviconCandidate best_favicon_candidate_; |
297 | 297 |
298 DISALLOW_COPY_AND_ASSIGN(FaviconHandler); | 298 DISALLOW_COPY_AND_ASSIGN(FaviconHandler); |
299 }; | 299 }; |
300 | 300 |
301 } // namespace favicon | 301 } // namespace favicon |
302 | 302 |
303 #endif // COMPONENTS_FAVICON_CORE_FAVICON_HANDLER_H_ | 303 #endif // COMPONENTS_FAVICON_CORE_FAVICON_HANDLER_H_ |
OLD | NEW |