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 // Called with the results from the download initiated via | |
| 116 // FaviconHandlerDelegate::StartDownload(). | |
| 117 // |image| is resized to how it should appear in the UI and be stored in | |
|
rjkroege
2012/09/07 16:45:46
Where is the image resized?
| |
| 118 // history. | |
| 115 void OnDidDownloadFavicon(int id, | 119 void OnDidDownloadFavicon(int id, |
| 116 const GURL& image_url, | 120 const GURL& image_url, |
| 117 bool errored, | 121 bool errored, |
| 118 const gfx::Image& image, | 122 const gfx::Image& image, |
| 119 float score); | 123 float score); |
| 120 | 124 |
| 121 // For testing. | 125 // For testing. |
| 122 const std::deque<FaviconURL>& image_urls() const { return image_urls_; } | 126 const std::deque<FaviconURL>& image_urls() const { return image_urls_; } |
| 123 | 127 |
| 124 protected: | 128 protected: |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 238 history::IconType icon_type); | 242 history::IconType icon_type); |
| 239 | 243 |
| 240 // Converts the FAVICON's image data to an SkBitmap and sets it on the | 244 // Converts the FAVICON's image data to an SkBitmap and sets it on the |
| 241 // NavigationEntry. | 245 // NavigationEntry. |
| 242 // If the WebContents has a delegate, it is notified of the new favicon | 246 // If the WebContents has a delegate, it is notified of the new favicon |
| 243 // (INVALIDATE_FAVICON). | 247 // (INVALIDATE_FAVICON). |
| 244 void UpdateFavicon(content::NavigationEntry* entry, | 248 void UpdateFavicon(content::NavigationEntry* entry, |
| 245 const std::vector<history::FaviconBitmapResult>& favicon_bitmap_results); | 249 const std::vector<history::FaviconBitmapResult>& favicon_bitmap_results); |
| 246 void UpdateFavicon(content::NavigationEntry* entry, const gfx::Image* image); | 250 void UpdateFavicon(content::NavigationEntry* entry, const gfx::Image* image); |
| 247 | 251 |
| 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(); | 252 void FetchFaviconInternal(); |
| 254 | 253 |
| 255 // Return the current candidate if any. | 254 // Return the current candidate if any. |
| 256 FaviconURL* current_candidate() { | 255 FaviconURL* current_candidate() { |
| 257 return (image_urls_.size() > 0) ? &image_urls_[0] : NULL; | 256 return (image_urls_.size() > 0) ? &image_urls_[0] : NULL; |
| 258 } | 257 } |
| 259 | 258 |
| 260 // Returns the preferred_icon_size according icon_types_, 0 means no | 259 // Returns the preferred_icon_size according icon_types_, 0 means no |
| 261 // preference. | 260 // preference. |
| 262 int preferred_icon_size() { | 261 int preferred_icon_size() { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 298 // This handler's delegate. | 297 // This handler's delegate. |
| 299 FaviconHandlerDelegate* delegate_; // weak | 298 FaviconHandlerDelegate* delegate_; // weak |
| 300 | 299 |
| 301 // Current favicon candidate. | 300 // Current favicon candidate. |
| 302 FaviconCandidate favicon_candidate_; | 301 FaviconCandidate favicon_candidate_; |
| 303 | 302 |
| 304 DISALLOW_COPY_AND_ASSIGN(FaviconHandler); | 303 DISALLOW_COPY_AND_ASSIGN(FaviconHandler); |
| 305 }; | 304 }; |
| 306 | 305 |
| 307 #endif // CHROME_BROWSER_FAVICON_FAVICON_HANDLER_H_ | 306 #endif // CHROME_BROWSER_FAVICON_FAVICON_HANDLER_H_ |
| OLD | NEW |