Chromium Code Reviews| 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" |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 105 | 105 |
| 106 // Message Handler. Must be public, because also called from | 106 // Message Handler. Must be public, because also called from |
| 107 // PrerenderContents. Collects the |image_urls| list. | 107 // PrerenderContents. Collects the |image_urls| list. |
| 108 void OnUpdateFaviconURL(int32 page_id, | 108 void OnUpdateFaviconURL(int32 page_id, |
| 109 const std::vector<FaviconURL>& candidates); | 109 const std::vector<FaviconURL>& candidates); |
| 110 | 110 |
| 111 // Processes the current image_irls_ entry, requesting the image from the | 111 // Processes the current image_irls_ entry, requesting the image from the |
| 112 // history / download service. | 112 // history / download service. |
| 113 void ProcessCurrentUrl(); | 113 void ProcessCurrentUrl(); |
| 114 | 114 |
| 115 void OnDidDownloadFavicon(int id, | 115 void OnDidDownloadFavicon(int id, |
|
rjkroege
2012/09/10 15:57:08
nit: My preference would be for this to have a com
pkotwicz
2012/09/10 17:34:38
Done.
| |
| 116 const GURL& image_url, | 116 const GURL& image_url, |
| 117 bool errored, | 117 bool errored, |
| 118 const gfx::Image& image, | 118 int requested_size, |
| 119 float score); | 119 const std::vector<SkBitmap>& bitmaps); |
| 120 | 120 |
| 121 // For testing. | 121 // For testing. |
| 122 const std::deque<FaviconURL>& image_urls() const { return image_urls_; } | 122 const std::deque<FaviconURL>& image_urls() const { return image_urls_; } |
| 123 | 123 |
| 124 protected: | 124 protected: |
| 125 // These virtual methods make FaviconHandler testable and are overridden by | 125 // These virtual methods make FaviconHandler testable and are overridden by |
| 126 // TestFaviconHandler. | 126 // TestFaviconHandler. |
| 127 | 127 |
| 128 // Return the NavigationEntry for the active entry, or NULL if the active | 128 // Return the NavigationEntry for the active entry, or NULL if the active |
| 129 // entries URL does not match that of the URL last passed to FetchFavicon. | 129 // entries URL does not match that of the URL last passed to FetchFavicon. |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 238 history::IconType icon_type); | 238 history::IconType icon_type); |
| 239 | 239 |
| 240 // Converts the FAVICON's image data to an SkBitmap and sets it on the | 240 // Converts the FAVICON's image data to an SkBitmap and sets it on the |
| 241 // NavigationEntry. | 241 // NavigationEntry. |
| 242 // If the WebContents has a delegate, it is notified of the new favicon | 242 // If the WebContents has a delegate, it is notified of the new favicon |
| 243 // (INVALIDATE_FAVICON). | 243 // (INVALIDATE_FAVICON). |
| 244 void UpdateFavicon(content::NavigationEntry* entry, | 244 void UpdateFavicon(content::NavigationEntry* entry, |
| 245 const std::vector<history::FaviconBitmapResult>& favicon_bitmap_results); | 245 const std::vector<history::FaviconBitmapResult>& favicon_bitmap_results); |
| 246 void UpdateFavicon(content::NavigationEntry* entry, const gfx::Image* image); | 246 void UpdateFavicon(content::NavigationEntry* entry, const gfx::Image* image); |
| 247 | 247 |
| 248 // If the image is not already at its preferred size, scales the image such | |
| 249 // that either the width and/or height == gfx::kFaviconSize. Does nothing if | |
| 250 // the image is empty. | |
| 251 gfx::Image ResizeFaviconIfNeeded(const gfx::Image& image); | |
| 252 | |
| 253 void FetchFaviconInternal(); | 248 void FetchFaviconInternal(); |
| 254 | 249 |
| 255 // Return the current candidate if any. | 250 // Return the current candidate if any. |
| 256 FaviconURL* current_candidate() { | 251 FaviconURL* current_candidate() { |
| 257 return (image_urls_.size() > 0) ? &image_urls_[0] : NULL; | 252 return (image_urls_.size() > 0) ? &image_urls_[0] : NULL; |
| 258 } | 253 } |
| 259 | 254 |
| 260 // Returns the preferred_icon_size according icon_types_, 0 means no | 255 // Returns the preferred_icon_size according icon_types_, 0 means no |
| 261 // preference. | 256 // preference. |
| 262 int preferred_icon_size() { | 257 int preferred_icon_size() { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 298 // This handler's delegate. | 293 // This handler's delegate. |
| 299 FaviconHandlerDelegate* delegate_; // weak | 294 FaviconHandlerDelegate* delegate_; // weak |
| 300 | 295 |
| 301 // Current favicon candidate. | 296 // Current favicon candidate. |
| 302 FaviconCandidate favicon_candidate_; | 297 FaviconCandidate favicon_candidate_; |
| 303 | 298 |
| 304 DISALLOW_COPY_AND_ASSIGN(FaviconHandler); | 299 DISALLOW_COPY_AND_ASSIGN(FaviconHandler); |
| 305 }; | 300 }; |
| 306 | 301 |
| 307 #endif // CHROME_BROWSER_FAVICON_FAVICON_HANDLER_H_ | 302 #endif // CHROME_BROWSER_FAVICON_FAVICON_HANDLER_H_ |
| OLD | NEW |