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 <map> | 8 #include <map> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 void OnUpdateFaviconURL(int32 page_id, | 108 void OnUpdateFaviconURL(int32 page_id, |
109 const std::vector<FaviconURL>& candidates); | 109 const std::vector<FaviconURL>& candidates); |
110 | 110 |
111 // Processes the current image_irls_ entry, requesting the image from the | 111 // Processes the current image_irls_ entry, requesting the image from the |
112 // history / download service. | 112 // history / download service. |
113 void ProcessCurrentUrl(); | 113 void ProcessCurrentUrl(); |
114 | 114 |
115 void OnDidDownloadFavicon(int id, | 115 void OnDidDownloadFavicon(int id, |
116 const GURL& image_url, | 116 const GURL& image_url, |
117 bool errored, | 117 bool errored, |
118 const gfx::Image& image); | 118 const gfx::Image& image, |
| 119 float score); |
119 | 120 |
120 // For testing. | 121 // For testing. |
121 const std::deque<FaviconURL>& image_urls() const { return image_urls_; } | 122 const std::deque<FaviconURL>& image_urls() const { return image_urls_; } |
122 | 123 |
123 protected: | 124 protected: |
124 // These virtual methods make FaviconHandler testable and are overridden by | 125 // These virtual methods make FaviconHandler testable and are overridden by |
125 // TestFaviconHandler. | 126 // TestFaviconHandler. |
126 | 127 |
127 // Return the NavigationEntry for the active entry, or NULL if the active | 128 // Return the NavigationEntry for the active entry, or NULL if the active |
128 // entries URL does not match that of the URL last passed to FetchFavicon. | 129 // entries URL does not match that of the URL last passed to FetchFavicon. |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 history::IconType icon_type; | 180 history::IconType icon_type; |
180 }; | 181 }; |
181 | 182 |
182 struct FaviconCandidate { | 183 struct FaviconCandidate { |
183 FaviconCandidate(); | 184 FaviconCandidate(); |
184 ~FaviconCandidate(); | 185 ~FaviconCandidate(); |
185 | 186 |
186 FaviconCandidate(const GURL& url, | 187 FaviconCandidate(const GURL& url, |
187 const GURL& image_url, | 188 const GURL& image_url, |
188 const gfx::Image& image, | 189 const gfx::Image& image, |
189 int bitmap_size, | 190 float score, |
190 history::IconType icon_type); | 191 history::IconType icon_type); |
191 | 192 |
192 GURL url; | 193 GURL url; |
193 GURL image_url; | 194 GURL image_url; |
194 gfx::Image image; | 195 gfx::Image image; |
195 int bitmap_size; | 196 float score; |
196 history::IconType icon_type; | 197 history::IconType icon_type; |
197 }; | 198 }; |
198 | 199 |
199 // See description above class for details. | 200 // See description above class for details. |
200 void OnFaviconDataForInitialURL(FaviconService::Handle handle, | 201 void OnFaviconDataForInitialURL(FaviconService::Handle handle, |
201 history::FaviconData favicon); | 202 history::FaviconData favicon); |
202 | 203 |
203 // If the favicon has expired, asks the renderer to download the favicon. | 204 // If the favicon has expired, asks the renderer to download the favicon. |
204 // Otherwise asks history to update the mapping between page url and icon | 205 // Otherwise asks history to update the mapping between page url and icon |
205 // url with a callback to OnFaviconData when done. | 206 // url with a callback to OnFaviconData when done. |
(...skipping 10 matching lines...) Expand all Loading... |
216 int ScheduleDownload(const GURL& url, | 217 int ScheduleDownload(const GURL& url, |
217 const GURL& image_url, | 218 const GURL& image_url, |
218 int image_size, | 219 int image_size, |
219 history::IconType icon_type, | 220 history::IconType icon_type, |
220 const FaviconTabHelper::ImageDownloadCallback& callback); | 221 const FaviconTabHelper::ImageDownloadCallback& callback); |
221 | 222 |
222 // Updates |favicon_candidate_| and returns true if it is an exact match. | 223 // Updates |favicon_candidate_| and returns true if it is an exact match. |
223 bool UpdateFaviconCandidate(const GURL& url, | 224 bool UpdateFaviconCandidate(const GURL& url, |
224 const GURL& image_url, | 225 const GURL& image_url, |
225 const gfx::Image& image, | 226 const gfx::Image& image, |
| 227 float score, |
226 history::IconType icon_type); | 228 history::IconType icon_type); |
227 | 229 |
228 // Sets the image data for the favicon. | 230 // Sets the image data for the favicon. |
229 void SetFavicon(const GURL& url, | 231 void SetFavicon(const GURL& url, |
230 const GURL& icon_url, | 232 const GURL& icon_url, |
231 const gfx::Image& image, | 233 const gfx::Image& image, |
232 history::IconType icon_type); | 234 history::IconType icon_type); |
233 | 235 |
234 // Converts the FAVICON's image data to an SkBitmap and sets it on the | 236 // Converts the FAVICON's image data to an SkBitmap and sets it on the |
235 // NavigationEntry. | 237 // NavigationEntry. |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 // This handler's delegate. | 294 // This handler's delegate. |
293 FaviconHandlerDelegate* delegate_; // weak | 295 FaviconHandlerDelegate* delegate_; // weak |
294 | 296 |
295 // Current favicon candidate. | 297 // Current favicon candidate. |
296 FaviconCandidate favicon_candidate_; | 298 FaviconCandidate favicon_candidate_; |
297 | 299 |
298 DISALLOW_COPY_AND_ASSIGN(FaviconHandler); | 300 DISALLOW_COPY_AND_ASSIGN(FaviconHandler); |
299 }; | 301 }; |
300 | 302 |
301 #endif // CHROME_BROWSER_FAVICON_FAVICON_HANDLER_H_ | 303 #endif // CHROME_BROWSER_FAVICON_FAVICON_HANDLER_H_ |
OLD | NEW |