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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 private: | 151 private: |
152 friend class TestFaviconHandler; // For testing | 152 // For testing: |
| 153 friend class FaviconTabHelperTest; |
| 154 friend class TestFaviconHandler; |
153 | 155 |
154 // Represents an in progress download of an image from the renderer. | 156 // Represents an in progress download of an image from the renderer. |
155 struct DownloadRequest { | 157 struct DownloadRequest { |
156 DownloadRequest(); | 158 DownloadRequest(); |
157 ~DownloadRequest(); | 159 ~DownloadRequest(); |
158 | 160 |
159 DownloadRequest(const GURL& url, | 161 DownloadRequest(const GURL& url, |
160 const GURL& image_url, | 162 const GURL& image_url, |
161 favicon_base::IconType icon_type); | 163 favicon_base::IconType icon_type); |
162 | 164 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 // Additionally removes any entries whose sizes are all greater than the max | 253 // Additionally removes any entries whose sizes are all greater than the max |
252 // allowed size. | 254 // allowed size. |
253 void SortAndPruneImageUrls(); | 255 void SortAndPruneImageUrls(); |
254 | 256 |
255 // Used for FaviconService requests. | 257 // Used for FaviconService requests. |
256 base::CancelableTaskTracker cancelable_task_tracker_; | 258 base::CancelableTaskTracker cancelable_task_tracker_; |
257 | 259 |
258 // URL of the page we're requesting the favicon for. | 260 // URL of the page we're requesting the favicon for. |
259 GURL url_; | 261 GURL url_; |
260 | 262 |
261 // Whether we got the initial response for the favicon back from the renderer. | 263 // Whether we are waiting for data from the FaviconService. |
| 264 bool waiting_for_favicon_service_data_; |
| 265 |
| 266 // Whether we got data back for the initial request to the FaviconService. |
262 bool got_favicon_from_history_; | 267 bool got_favicon_from_history_; |
263 | 268 |
264 // Whether the favicon is out of date or the favicon data in | 269 // Whether the favicon is out of date or the favicon data in |
265 // |history_results_| is known to be incomplete. If true, it means history | 270 // |history_results_| is known to be incomplete. If true, it means history |
266 // knows about the favicon, but we need to download the favicon because the | 271 // knows about the favicon, but we need to download the favicon because the |
267 // icon has expired or the data in the database is incomplete. | 272 // icon has expired or the data in the database is incomplete. |
268 bool favicon_expired_or_incomplete_; | 273 bool favicon_expired_or_incomplete_; |
269 | 274 |
270 // Requests to the renderer to download favicons. | 275 // Requests to the renderer to download favicons. |
271 typedef std::map<int, DownloadRequest> DownloadRequests; | 276 typedef std::map<int, DownloadRequest> DownloadRequests; |
(...skipping 20 matching lines...) Expand all Loading... |
292 // Best image we've seen so far. As images are downloaded from the page they | 297 // 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 | 298 // 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 | 299 // available the favicon service and the current page are updated (assuming |
295 // the image is for a favicon). | 300 // the image is for a favicon). |
296 FaviconCandidate best_favicon_candidate_; | 301 FaviconCandidate best_favicon_candidate_; |
297 | 302 |
298 DISALLOW_COPY_AND_ASSIGN(FaviconHandler); | 303 DISALLOW_COPY_AND_ASSIGN(FaviconHandler); |
299 }; | 304 }; |
300 | 305 |
301 #endif // CHROME_BROWSER_FAVICON_FAVICON_HANDLER_H_ | 306 #endif // CHROME_BROWSER_FAVICON_FAVICON_HANDLER_H_ |
OLD | NEW |