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