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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 base::CancelableTaskTracker* tracker); | 141 base::CancelableTaskTracker* tracker); |
142 | 142 |
143 virtual void SetHistoryFavicons(const GURL& page_url, | 143 virtual void SetHistoryFavicons(const GURL& page_url, |
144 const GURL& icon_url, | 144 const GURL& icon_url, |
145 favicon_base::IconType icon_type, | 145 favicon_base::IconType icon_type, |
146 const gfx::Image& image); | 146 const gfx::Image& image); |
147 | 147 |
148 // Returns true if the favicon should be saved. | 148 // Returns true if the favicon should be saved. |
149 virtual bool ShouldSaveFavicon(const GURL& url); | 149 virtual bool ShouldSaveFavicon(const GURL& url); |
150 | 150 |
151 // Notifies the driver that the favicon for the active entry was updated. | |
152 // |icon_url_changed| is true if a favicon with a different icon URL has been | |
153 // selected since the previous call to NotifyFaviconUpdated(). | |
154 virtual void NotifyFaviconUpdated(bool icon_url_changed); | |
155 | |
156 private: | 151 private: |
157 friend class TestFaviconHandler; // For testing | 152 friend class TestFaviconHandler; // For testing |
158 | 153 |
159 // Represents an in progress download of an image from the renderer. | 154 // Represents an in progress download of an image from the renderer. |
160 struct DownloadRequest { | 155 struct DownloadRequest { |
161 DownloadRequest(); | 156 DownloadRequest(); |
162 ~DownloadRequest(); | 157 ~DownloadRequest(); |
163 | 158 |
164 DownloadRequest(const GURL& url, | 159 DownloadRequest(const GURL& url, |
165 const GURL& image_url, | 160 const GURL& image_url, |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 const gfx::Image& image, | 214 const gfx::Image& image, |
220 float score, | 215 float score, |
221 favicon_base::IconType icon_type); | 216 favicon_base::IconType icon_type); |
222 | 217 |
223 // Sets the image data for the favicon. | 218 // Sets the image data for the favicon. |
224 void SetFavicon(const GURL& url, | 219 void SetFavicon(const GURL& url, |
225 const GURL& icon_url, | 220 const GURL& icon_url, |
226 const gfx::Image& image, | 221 const gfx::Image& image, |
227 favicon_base::IconType icon_type); | 222 favicon_base::IconType icon_type); |
228 | 223 |
229 // Sets the favicon's data. | 224 // Notifies |driver_| favicon available. See |
230 void SetFaviconOnActivePage(const std::vector< | 225 // FaviconDriver::NotifyFaviconAvailable() for |is_active_favicon| in detail. |
231 favicon_base::FaviconRawBitmapResult>& favicon_bitmap_results); | 226 void NotifyFaviconAvailable( |
232 void SetFaviconOnActivePage(const GURL& icon_url, const gfx::Image& image); | 227 const std::vector<favicon_base::FaviconRawBitmapResult>& |
| 228 favicon_bitmap_results, |
| 229 bool is_active_favicon); |
| 230 void NotifyFaviconAvailable(const GURL& icon_url, |
| 231 const gfx::Image& image, |
| 232 bool is_active_favicon); |
233 | 233 |
234 // Return the current candidate if any. | 234 // Return the current candidate if any. |
235 favicon::FaviconURL* current_candidate() { | 235 favicon::FaviconURL* current_candidate() { |
236 return (!image_urls_.empty()) ? &image_urls_.front() : NULL; | 236 return (!image_urls_.empty()) ? &image_urls_.front() : NULL; |
237 } | 237 } |
238 | 238 |
239 // Returns whether the page's url changed since the favicon was requested. | 239 // Returns whether the page's url changed since the favicon was requested. |
240 bool PageChangedSinceFaviconWasRequested(); | 240 bool PageChangedSinceFaviconWasRequested(); |
241 | 241 |
242 // Returns the preferred size of the image. 0 means no preference (any size | 242 // Returns the preferred size of the image. 0 means no preference (any size |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 // Best image we've seen so far. As images are downloaded from the page they | 292 // Best image we've seen so far. As images are downloaded from the page they |
293 // are stored here. When there is an exact match, or no more images are | 293 // are stored here. When there is an exact match, or no more images are |
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 #endif // CHROME_BROWSER_FAVICON_FAVICON_HANDLER_H_ | 301 #endif // CHROME_BROWSER_FAVICON_FAVICON_HANDLER_H_ |
OLD | NEW |