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" |
11 #include "base/callback_forward.h" | 11 #include "base/callback_forward.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/task/cancelable_task_tracker.h" | 13 #include "base/task/cancelable_task_tracker.h" |
14 #include "chrome/browser/favicon/favicon_service.h" | 14 #include "chrome/browser/favicon/favicon_service.h" |
15 #include "chrome/browser/favicon/favicon_tab_helper.h" | 15 #include "chrome/browser/favicon/favicon_tab_helper.h" |
16 #include "chrome/common/ref_counted_util.h" | 16 #include "chrome/common/ref_counted_util.h" |
17 #include "content/public/common/favicon_url.h" | 17 #include "content/public/common/favicon_url.h" |
18 #include "ui/gfx/favicon_size.h" | 18 #include "ui/gfx/favicon_size.h" |
19 #include "ui/gfx/image/image.h" | 19 #include "ui/gfx/image/image.h" |
20 #include "url/gurl.h" | 20 #include "url/gurl.h" |
21 | 21 |
| 22 class FaviconClient; |
22 class FaviconDriver; | 23 class FaviconDriver; |
23 class FaviconHandlerDelegate; | 24 class FaviconHandlerDelegate; |
24 class Profile; | 25 class Profile; |
25 class SkBitmap; | 26 class SkBitmap; |
26 | 27 |
27 namespace base { | 28 namespace base { |
28 class RefCountedMemory; | 29 class RefCountedMemory; |
29 } | 30 } |
30 | 31 |
31 namespace content { | 32 namespace content { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 // NavigationEntry and notifies the database to save the favicon. | 79 // NavigationEntry and notifies the database to save the favicon. |
79 | 80 |
80 class FaviconHandler { | 81 class FaviconHandler { |
81 public: | 82 public: |
82 enum Type { | 83 enum Type { |
83 FAVICON, | 84 FAVICON, |
84 TOUCH, | 85 TOUCH, |
85 }; | 86 }; |
86 | 87 |
87 FaviconHandler(Profile* profile, | 88 FaviconHandler(Profile* profile, |
| 89 FaviconClient* client, |
88 FaviconDriver* driver, | 90 FaviconDriver* driver, |
89 FaviconHandlerDelegate* delegate, | 91 FaviconHandlerDelegate* delegate, |
90 Type icon_type); | 92 Type icon_type); |
91 virtual ~FaviconHandler(); | 93 virtual ~FaviconHandler(); |
92 | 94 |
93 // Initiates loading the favicon for the specified url. | 95 // Initiates loading the favicon for the specified url. |
94 void FetchFavicon(const GURL& url); | 96 void FetchFavicon(const GURL& url); |
95 | 97 |
96 // Message Handler. Must be public, because also called from | 98 // Message Handler. Must be public, because also called from |
97 // PrerenderContents. Collects the |image_urls| list. | 99 // PrerenderContents. Collects the |image_urls| list. |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 const GURL& page_url, | 149 const GURL& page_url, |
148 int icon_types, | 150 int icon_types, |
149 const FaviconService::FaviconResultsCallback& callback, | 151 const FaviconService::FaviconResultsCallback& callback, |
150 base::CancelableTaskTracker* tracker); | 152 base::CancelableTaskTracker* tracker); |
151 | 153 |
152 virtual void SetHistoryFavicons(const GURL& page_url, | 154 virtual void SetHistoryFavicons(const GURL& page_url, |
153 const GURL& icon_url, | 155 const GURL& icon_url, |
154 chrome::IconType icon_type, | 156 chrome::IconType icon_type, |
155 const gfx::Image& image); | 157 const gfx::Image& image); |
156 | 158 |
157 virtual FaviconService* GetFaviconService(); | |
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 delegate 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 |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 | 281 |
282 // The prioritized favicon candidates from the page back from the renderer. | 282 // The prioritized favicon candidates from the page back from the renderer. |
283 std::deque<content::FaviconURL> image_urls_; | 283 std::deque<content::FaviconURL> image_urls_; |
284 | 284 |
285 // The FaviconBitmapResults from history. | 285 // The FaviconBitmapResults from history. |
286 std::vector<chrome::FaviconBitmapResult> history_results_; | 286 std::vector<chrome::FaviconBitmapResult> history_results_; |
287 | 287 |
288 // The Profile associated with this handler. | 288 // The Profile associated with this handler. |
289 Profile* profile_; | 289 Profile* profile_; |
290 | 290 |
| 291 // The client which implements embedder-specific Favicon operations. |
| 292 FaviconClient* client_; // weak |
| 293 |
291 // The driver which implements platform-specific Favicon operations. | 294 // The driver which implements platform-specific Favicon operations. |
292 FaviconDriver* driver_; // weak | 295 FaviconDriver* driver_; // weak |
293 | 296 |
294 // This handler's delegate. | 297 // This handler's delegate. |
295 FaviconHandlerDelegate* delegate_; // weak | 298 FaviconHandlerDelegate* delegate_; // weak |
296 | 299 |
297 // 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 |
298 // 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 |
299 // available the favicon service and the NavigationEntry are updated (assuming | 302 // available the favicon service and the NavigationEntry are updated (assuming |
300 // the image is for a favicon). | 303 // the image is for a favicon). |
301 FaviconCandidate best_favicon_candidate_; | 304 FaviconCandidate best_favicon_candidate_; |
302 | 305 |
303 DISALLOW_COPY_AND_ASSIGN(FaviconHandler); | 306 DISALLOW_COPY_AND_ASSIGN(FaviconHandler); |
304 }; | 307 }; |
305 | 308 |
306 #endif // CHROME_BROWSER_FAVICON_FAVICON_HANDLER_H_ | 309 #endif // CHROME_BROWSER_FAVICON_FAVICON_HANDLER_H_ |
OLD | NEW |