| 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 10 matching lines...) Expand all Loading... |
| 21 #include "url/gurl.h" | 21 #include "url/gurl.h" |
| 22 | 22 |
| 23 class FaviconClient; | 23 class FaviconClient; |
| 24 class FaviconDriver; | 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 { | |
| 32 class NavigationEntry; | |
| 33 } | |
| 34 | 31 |
| 35 // FaviconHandler works with FaviconTabHelper to fetch the specific type of | 32 // FaviconHandler works with FaviconTabHelper to fetch the specific type of |
| 36 // favicon. | 33 // favicon. |
| 37 // | 34 // |
| 38 // FetchFavicon requests the favicon from the favicon service which in turn | 35 // FetchFavicon requests the favicon from the favicon service which in turn |
| 39 // requests the favicon from the history database. At this point | 36 // requests the favicon from the history database. At this point |
| 40 // we only know the URL of the page, and not necessarily the url of the | 37 // we only know the URL of the page, and not necessarily the url of the |
| 41 // favicon. To ensure we handle reloading stale favicons as well as | 38 // favicon. To ensure we handle reloading stale favicons as well as |
| 42 // reloading a favicon on page reload we always request the favicon from | 39 // reloading a favicon on page reload we always request the favicon from |
| 43 // history regardless of whether the NavigationEntry has a favicon. | 40 // history regardless of whether the NavigationEntry has a favicon. |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 | 113 |
| 117 // For testing. | 114 // For testing. |
| 118 const std::vector<content::FaviconURL>& image_urls() const { | 115 const std::vector<content::FaviconURL>& image_urls() const { |
| 119 return image_urls_; | 116 return image_urls_; |
| 120 } | 117 } |
| 121 | 118 |
| 122 protected: | 119 protected: |
| 123 // These virtual methods make FaviconHandler testable and are overridden by | 120 // These virtual methods make FaviconHandler testable and are overridden by |
| 124 // TestFaviconHandler. | 121 // TestFaviconHandler. |
| 125 | 122 |
| 126 // Return the NavigationEntry for the active entry, or NULL if the active | 123 // |
| 127 // entries URL does not match that of the URL last passed to FetchFavicon. | 124 // |
| 128 virtual content::NavigationEntry* GetEntry(); | 125 bool NavigationEntryConcernsFavicon(); |
| 129 | 126 |
| 130 // Asks the render to download favicon, returns the request id. | 127 // Asks the render to download favicon, returns the request id. |
| 131 virtual int DownloadFavicon(const GURL& image_url, int max_bitmap_size); | 128 virtual int DownloadFavicon(const GURL& image_url, int max_bitmap_size); |
| 132 | 129 |
| 133 // Ask the favicon from history | 130 // Ask the favicon from history |
| 134 virtual void UpdateFaviconMappingAndFetch( | 131 virtual void UpdateFaviconMappingAndFetch( |
| 135 const GURL& page_url, | 132 const GURL& page_url, |
| 136 const GURL& icon_url, | 133 const GURL& icon_url, |
| 137 favicon_base::IconType icon_type, | 134 favicon_base::IconType icon_type, |
| 138 const FaviconService::FaviconResultsCallback& callback, | 135 const FaviconService::FaviconResultsCallback& callback, |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 | 225 |
| 229 // Sets the image data for the favicon. | 226 // Sets the image data for the favicon. |
| 230 void SetFavicon(const GURL& url, | 227 void SetFavicon(const GURL& url, |
| 231 const GURL& icon_url, | 228 const GURL& icon_url, |
| 232 const gfx::Image& image, | 229 const gfx::Image& image, |
| 233 favicon_base::IconType icon_type); | 230 favicon_base::IconType icon_type); |
| 234 | 231 |
| 235 // Sets the favicon's data on the NavigationEntry. | 232 // Sets the favicon's data on the NavigationEntry. |
| 236 // If the WebContents has a delegate, it is invalidated (INVALIDATE_TYPE_TAB). | 233 // If the WebContents has a delegate, it is invalidated (INVALIDATE_TYPE_TAB). |
| 237 void SetFaviconOnNavigationEntry( | 234 void SetFaviconOnNavigationEntry( |
| 238 content::NavigationEntry* entry, | |
| 239 const std::vector<favicon_base::FaviconBitmapResult>& | 235 const std::vector<favicon_base::FaviconBitmapResult>& |
| 240 favicon_bitmap_results); | 236 favicon_bitmap_results); |
| 241 void SetFaviconOnNavigationEntry(content::NavigationEntry* entry, | 237 void SetFaviconOnNavigationEntry(const GURL& icon_url, |
| 242 const GURL& icon_url, | |
| 243 const gfx::Image& image); | 238 const gfx::Image& image); |
| 244 | 239 |
| 245 // Return the current candidate if any. | 240 // Return the current candidate if any. |
| 246 content::FaviconURL* current_candidate() { | 241 content::FaviconURL* current_candidate() { |
| 247 return (!image_urls_.empty()) ? &image_urls_.front() : NULL; | 242 return (!image_urls_.empty()) ? &image_urls_.front() : NULL; |
| 248 } | 243 } |
| 249 | 244 |
| 250 // Returns the preferred size of the image. 0 means no preference (any size | 245 // Returns the preferred size of the image. 0 means no preference (any size |
| 251 // will do). | 246 // will do). |
| 252 int preferred_icon_size() const { | 247 int preferred_icon_size() const { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 // Best image we've seen so far. As images are downloaded from the page they | 295 // Best image we've seen so far. As images are downloaded from the page they |
| 301 // are stored here. When there is an exact match, or no more images are | 296 // are stored here. When there is an exact match, or no more images are |
| 302 // available the favicon service and the NavigationEntry are updated (assuming | 297 // available the favicon service and the NavigationEntry are updated (assuming |
| 303 // the image is for a favicon). | 298 // the image is for a favicon). |
| 304 FaviconCandidate best_favicon_candidate_; | 299 FaviconCandidate best_favicon_candidate_; |
| 305 | 300 |
| 306 DISALLOW_COPY_AND_ASSIGN(FaviconHandler); | 301 DISALLOW_COPY_AND_ASSIGN(FaviconHandler); |
| 307 }; | 302 }; |
| 308 | 303 |
| 309 #endif // CHROME_BROWSER_FAVICON_FAVICON_HANDLER_H_ | 304 #endif // CHROME_BROWSER_FAVICON_FAVICON_HANDLER_H_ |
| OLD | NEW |