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> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/callback_forward.h" | 13 #include "base/callback_forward.h" |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "base/task/cancelable_task_tracker.h" | 15 #include "base/task/cancelable_task_tracker.h" |
16 #include "chrome/browser/favicon/favicon_service.h" | 16 #include "chrome/browser/favicon/favicon_service.h" |
17 #include "chrome/browser/favicon/favicon_tab_helper.h" | 17 #include "chrome/browser/favicon/favicon_tab_helper.h" |
18 #include "content/public/common/favicon_url.h" | 18 #include "content/public/common/favicon_url.h" |
19 #include "ui/gfx/favicon_size.h" | 19 #include "ui/gfx/favicon_size.h" |
20 #include "ui/gfx/image/image.h" | 20 #include "ui/gfx/image/image.h" |
21 #include "url/gurl.h" | 21 #include "url/gurl.h" |
22 | 22 |
23 class FaviconClient; | 23 class FaviconClient; |
24 class FaviconHandlerDelegate; | 24 class FaviconDriver; |
25 class SkBitmap; | 25 class SkBitmap; |
26 | 26 |
27 namespace base { | 27 namespace base { |
28 class RefCountedMemory; | 28 class RefCountedMemory; |
29 } | 29 } |
30 | 30 |
31 namespace content { | 31 namespace content { |
32 class NavigationEntry; | 32 class NavigationEntry; |
33 } | 33 } |
34 | 34 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 // favicon. | 80 // favicon. |
81 | 81 |
82 class FaviconHandler { | 82 class FaviconHandler { |
83 public: | 83 public: |
84 enum Type { | 84 enum Type { |
85 FAVICON, | 85 FAVICON, |
86 TOUCH, | 86 TOUCH, |
87 }; | 87 }; |
88 | 88 |
89 FaviconHandler(FaviconClient* client, | 89 FaviconHandler(FaviconClient* client, |
90 FaviconHandlerDelegate* delegate, | 90 FaviconDriver* driver, |
91 Type icon_type, | 91 Type icon_type, |
92 bool download_largest_icon); | 92 bool download_largest_icon); |
93 virtual ~FaviconHandler(); | 93 virtual ~FaviconHandler(); |
94 | 94 |
95 // Initiates loading the favicon for the specified url. | 95 // Initiates loading the favicon for the specified url. |
96 void FetchFavicon(const GURL& url); | 96 void FetchFavicon(const GURL& url); |
97 | 97 |
98 // Message Handler. Must be public, because also called from | 98 // Message Handler. Must be public, because also called from |
99 // PrerenderContents. Collects the |image_urls| list. | 99 // PrerenderContents. Collects the |image_urls| list. |
100 void OnUpdateFaviconURL(int32 page_id, | 100 void OnUpdateFaviconURL(int32 page_id, |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 base::CancelableTaskTracker* tracker); | 152 base::CancelableTaskTracker* tracker); |
153 | 153 |
154 virtual void SetHistoryFavicons(const GURL& page_url, | 154 virtual void SetHistoryFavicons(const GURL& page_url, |
155 const GURL& icon_url, | 155 const GURL& icon_url, |
156 favicon_base::IconType icon_type, | 156 favicon_base::IconType icon_type, |
157 const gfx::Image& image); | 157 const gfx::Image& image); |
158 | 158 |
159 // Returns true if the favicon should be saved. | 159 // Returns true if the favicon should be saved. |
160 virtual bool ShouldSaveFavicon(const GURL& url); | 160 virtual bool ShouldSaveFavicon(const GURL& url); |
161 | 161 |
162 // Notifies the delegate that the favicon for the active entry was updated. | 162 // Notifies the driver that the favicon for the active entry was updated. |
163 // |icon_url_changed| is true if a favicon with a different icon URL has been | 163 // |icon_url_changed| is true if a favicon with a different icon URL has been |
164 // selected since the previous call to NotifyFaviconUpdated(). | 164 // selected since the previous call to NotifyFaviconUpdated(). |
165 virtual void NotifyFaviconUpdated(bool icon_url_changed); | 165 virtual void NotifyFaviconUpdated(bool icon_url_changed); |
166 | 166 |
167 private: | 167 private: |
168 friend class TestFaviconHandler; // For testing | 168 friend class TestFaviconHandler; // For testing |
169 | 169 |
170 // Represents an in progress download of an image from the renderer. | 170 // Represents an in progress download of an image from the renderer. |
171 struct DownloadRequest { | 171 struct DownloadRequest { |
172 DownloadRequest(); | 172 DownloadRequest(); |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 | 288 |
289 // The prioritized favicon candidates from the page back from the renderer. | 289 // The prioritized favicon candidates from the page back from the renderer. |
290 std::vector<content::FaviconURL> image_urls_; | 290 std::vector<content::FaviconURL> image_urls_; |
291 | 291 |
292 // The FaviconBitmapResults from history. | 292 // The FaviconBitmapResults from history. |
293 std::vector<favicon_base::FaviconBitmapResult> history_results_; | 293 std::vector<favicon_base::FaviconBitmapResult> history_results_; |
294 | 294 |
295 // The client which implements embedder-specific Favicon operations. | 295 // The client which implements embedder-specific Favicon operations. |
296 FaviconClient* client_; // weak | 296 FaviconClient* client_; // weak |
297 | 297 |
298 // This handler's delegate. | 298 // This handler's driver. |
299 FaviconHandlerDelegate* delegate_; // weak | 299 FaviconDriver* driver_; // weak |
300 | 300 |
301 // Best image we've seen so far. As images are downloaded from the page they | 301 // Best image we've seen so far. As images are downloaded from the page they |
302 // are stored here. When there is an exact match, or no more images are | 302 // are stored here. When there is an exact match, or no more images are |
303 // available the favicon service and the NavigationEntry are updated (assuming | 303 // available the favicon service and the NavigationEntry are updated (assuming |
304 // the image is for a favicon). | 304 // the image is for a favicon). |
305 FaviconCandidate best_favicon_candidate_; | 305 FaviconCandidate best_favicon_candidate_; |
306 | 306 |
307 DISALLOW_COPY_AND_ASSIGN(FaviconHandler); | 307 DISALLOW_COPY_AND_ASSIGN(FaviconHandler); |
308 }; | 308 }; |
309 | 309 |
310 #endif // CHROME_BROWSER_FAVICON_FAVICON_HANDLER_H_ | 310 #endif // CHROME_BROWSER_FAVICON_FAVICON_HANDLER_H_ |
OLD | NEW |