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

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

Issue 11411180: move favicon download code from chrome/ into content/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix order Created 8 years 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
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"
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 "chrome/browser/common/cancelable_request.h" 13 #include "chrome/browser/common/cancelable_request.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/favicon_url.h"
17 #include "chrome/common/ref_counted_util.h" 16 #include "chrome/common/ref_counted_util.h"
17 #include "content/public/common/favicon_url.h"
18 #include "googleurl/src/gurl.h" 18 #include "googleurl/src/gurl.h"
19 #include "ui/gfx/favicon_size.h" 19 #include "ui/gfx/favicon_size.h"
20 #include "ui/gfx/image/image.h" 20 #include "ui/gfx/image/image.h"
21 21
22 class FaviconHandlerDelegate; 22 class FaviconHandlerDelegate;
23 class Profile; 23 class Profile;
24 class SkBitmap; 24 class SkBitmap;
25 25
26 namespace base { 26 namespace base {
27 class RefCountedMemory; 27 class RefCountedMemory;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 FaviconHandlerDelegate* delegate, 87 FaviconHandlerDelegate* delegate,
88 Type icon_type); 88 Type icon_type);
89 virtual ~FaviconHandler(); 89 virtual ~FaviconHandler();
90 90
91 // Initiates loading the favicon for the specified url. 91 // Initiates loading the favicon for the specified url.
92 void FetchFavicon(const GURL& url); 92 void FetchFavicon(const GURL& url);
93 93
94 // Message Handler. Must be public, because also called from 94 // Message Handler. Must be public, because also called from
95 // PrerenderContents. Collects the |image_urls| list. 95 // PrerenderContents. Collects the |image_urls| list.
96 void OnUpdateFaviconURL(int32 page_id, 96 void OnUpdateFaviconURL(int32 page_id,
97 const std::vector<FaviconURL>& candidates); 97 const std::vector<content::FaviconURL>& candidates);
98 98
99 // Processes the current image_irls_ entry, requesting the image from the 99 // Processes the current image_irls_ entry, requesting the image from the
100 // history / download service. 100 // history / download service.
101 void ProcessCurrentUrl(); 101 void ProcessCurrentUrl();
102 102
103 // Message handler for IconHostMsg_DidDownloadFavicon. Called when the icon 103 // Message handler for IconHostMsg_DidDownloadFavicon. Called when the icon
104 // at |image_url| has been downloaded. 104 // at |image_url| has been downloaded.
105 // |bitmaps| is a list of all the frames of the icon at |image_url|. 105 // |bitmaps| is a list of all the frames of the icon at |image_url|.
106 void OnDidDownloadFavicon(int id, 106 void OnDidDownloadFavicon(int id,
107 const GURL& image_url, 107 const GURL& image_url,
108 bool errored, 108 bool errored,
109 int requested_size, 109 int requested_size,
110 const std::vector<SkBitmap>& bitmaps); 110 const std::vector<SkBitmap>& bitmaps);
111 111
112 // For testing. 112 // For testing.
113 const std::deque<FaviconURL>& image_urls() const { return image_urls_; } 113 const std::deque<content::FaviconURL>& image_urls() const {
114 return image_urls_;
115 }
114 116
115 protected: 117 protected:
116 // These virtual methods make FaviconHandler testable and are overridden by 118 // These virtual methods make FaviconHandler testable and are overridden by
117 // TestFaviconHandler. 119 // TestFaviconHandler.
118 120
119 // Return the NavigationEntry for the active entry, or NULL if the active 121 // Return the NavigationEntry for the active entry, or NULL if the active
120 // entries URL does not match that of the URL last passed to FetchFavicon. 122 // entries URL does not match that of the URL last passed to FetchFavicon.
121 virtual content::NavigationEntry* GetEntry(); 123 virtual content::NavigationEntry* GetEntry();
122 124
123 // Asks the render to download favicon, returns the request id. 125 // Asks the render to download favicon, returns the request id.
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 // NavigationEntry. 232 // NavigationEntry.
231 // If the WebContents has a delegate, it is notified of the new favicon 233 // If the WebContents has a delegate, it is notified of the new favicon
232 // (INVALIDATE_FAVICON). 234 // (INVALIDATE_FAVICON).
233 void UpdateFavicon(content::NavigationEntry* entry, 235 void UpdateFavicon(content::NavigationEntry* entry,
234 const std::vector<history::FaviconBitmapResult>& favicon_bitmap_results); 236 const std::vector<history::FaviconBitmapResult>& favicon_bitmap_results);
235 void UpdateFavicon(content::NavigationEntry* entry, const gfx::Image* image); 237 void UpdateFavicon(content::NavigationEntry* entry, const gfx::Image* image);
236 238
237 void FetchFaviconInternal(); 239 void FetchFaviconInternal();
238 240
239 // Return the current candidate if any. 241 // Return the current candidate if any.
240 FaviconURL* current_candidate() { 242 content::FaviconURL* current_candidate() {
241 return (image_urls_.size() > 0) ? &image_urls_[0] : NULL; 243 return (image_urls_.size() > 0) ? &image_urls_[0] : NULL;
242 } 244 }
243 245
244 // Returns the preferred_icon_size according icon_types_, 0 means no 246 // Returns the preferred_icon_size according icon_types_, 0 means no
245 // preference. 247 // preference.
246 int preferred_icon_size() { 248 int preferred_icon_size() {
247 return icon_types_ == history::FAVICON ? gfx::kFaviconSize : 0; 249 return icon_types_ == history::FAVICON ? gfx::kFaviconSize : 0;
248 } 250 }
249 251
250 // Used for history requests. 252 // Used for history requests.
(...skipping 13 matching lines...) Expand all
264 bool favicon_expired_or_incomplete_; 266 bool favicon_expired_or_incomplete_;
265 267
266 // Requests to the renderer to download favicons. 268 // Requests to the renderer to download favicons.
267 typedef std::map<int, DownloadRequest> DownloadRequests; 269 typedef std::map<int, DownloadRequest> DownloadRequests;
268 DownloadRequests download_requests_; 270 DownloadRequests download_requests_;
269 271
270 // The combination of the supported icon types. 272 // The combination of the supported icon types.
271 const int icon_types_; 273 const int icon_types_;
272 274
273 // The prioritized favicon candidates from the page back from the renderer. 275 // The prioritized favicon candidates from the page back from the renderer.
274 std::deque<FaviconURL> image_urls_; 276 std::deque<content::FaviconURL> image_urls_;
275 277
276 // The FaviconBitmapResults from history. 278 // The FaviconBitmapResults from history.
277 std::vector<history::FaviconBitmapResult> history_results_; 279 std::vector<history::FaviconBitmapResult> history_results_;
278 280
279 // The Profile associated with this handler. 281 // The Profile associated with this handler.
280 Profile* profile_; 282 Profile* profile_;
281 283
282 // This handler's delegate. 284 // This handler's delegate.
283 FaviconHandlerDelegate* delegate_; // weak 285 FaviconHandlerDelegate* delegate_; // weak
284 286
285 // Current favicon candidate. 287 // Current favicon candidate.
286 FaviconCandidate favicon_candidate_; 288 FaviconCandidate favicon_candidate_;
287 289
288 DISALLOW_COPY_AND_ASSIGN(FaviconHandler); 290 DISALLOW_COPY_AND_ASSIGN(FaviconHandler);
289 }; 291 };
290 292
291 #endif // CHROME_BROWSER_FAVICON_FAVICON_HANDLER_H_ 293 #endif // CHROME_BROWSER_FAVICON_FAVICON_HANDLER_H_
OLDNEW
« no previous file with comments | « chrome/browser/favicon/favicon_download_helper_delegate.h ('k') | chrome/browser/favicon/favicon_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698