Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(107)

Side by Side Diff: chrome/browser/favicon/favicon_handler.h

Issue 10911149: Cleanup FaviconHandler (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/favicon/favicon_handler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 // Message handler for IconHostMsg_DidDownloadFavicon. Called when the icon
116 // at |image_url| has been downloaded.
117 // |bitmaps| is a list of all the frames of the icon at |image_url|.
115 void OnDidDownloadFavicon(int id, 118 void OnDidDownloadFavicon(int id,
116 const GURL& image_url, 119 const GURL& image_url,
117 bool errored, 120 bool errored,
118 const gfx::Image& image, 121 int requested_size,
119 float score); 122 const std::vector<SkBitmap>& bitmaps);
120 123
121 // For testing. 124 // For testing.
122 const std::deque<FaviconURL>& image_urls() const { return image_urls_; } 125 const std::deque<FaviconURL>& image_urls() const { return image_urls_; }
123 126
124 protected: 127 protected:
125 // These virtual methods make FaviconHandler testable and are overridden by 128 // These virtual methods make FaviconHandler testable and are overridden by
126 // TestFaviconHandler. 129 // TestFaviconHandler.
127 130
128 // Return the NavigationEntry for the active entry, or NULL if the active 131 // 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. 132 // 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
238 history::IconType icon_type); 241 history::IconType icon_type);
239 242
240 // Converts the FAVICON's image data to an SkBitmap and sets it on the 243 // Converts the FAVICON's image data to an SkBitmap and sets it on the
241 // NavigationEntry. 244 // NavigationEntry.
242 // If the WebContents has a delegate, it is notified of the new favicon 245 // If the WebContents has a delegate, it is notified of the new favicon
243 // (INVALIDATE_FAVICON). 246 // (INVALIDATE_FAVICON).
244 void UpdateFavicon(content::NavigationEntry* entry, 247 void UpdateFavicon(content::NavigationEntry* entry,
245 const std::vector<history::FaviconBitmapResult>& favicon_bitmap_results); 248 const std::vector<history::FaviconBitmapResult>& favicon_bitmap_results);
246 void UpdateFavicon(content::NavigationEntry* entry, const gfx::Image* image); 249 void UpdateFavicon(content::NavigationEntry* entry, const gfx::Image* image);
247 250
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(); 251 void FetchFaviconInternal();
254 252
255 // Return the current candidate if any. 253 // Return the current candidate if any.
256 FaviconURL* current_candidate() { 254 FaviconURL* current_candidate() {
257 return (image_urls_.size() > 0) ? &image_urls_[0] : NULL; 255 return (image_urls_.size() > 0) ? &image_urls_[0] : NULL;
258 } 256 }
259 257
260 // Returns the preferred_icon_size according icon_types_, 0 means no 258 // Returns the preferred_icon_size according icon_types_, 0 means no
261 // preference. 259 // preference.
262 int preferred_icon_size() { 260 int preferred_icon_size() {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 // This handler's delegate. 296 // This handler's delegate.
299 FaviconHandlerDelegate* delegate_; // weak 297 FaviconHandlerDelegate* delegate_; // weak
300 298
301 // Current favicon candidate. 299 // Current favicon candidate.
302 FaviconCandidate favicon_candidate_; 300 FaviconCandidate favicon_candidate_;
303 301
304 DISALLOW_COPY_AND_ASSIGN(FaviconHandler); 302 DISALLOW_COPY_AND_ASSIGN(FaviconHandler);
305 }; 303 };
306 304
307 #endif // CHROME_BROWSER_FAVICON_FAVICON_HANDLER_H_ 305 #endif // CHROME_BROWSER_FAVICON_FAVICON_HANDLER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/favicon/favicon_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698