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

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

Issue 11195010: Extract Favicon Download logic from FaviconTabHelper (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: DEPS and nits Created 8 years, 2 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_FAVICON_FAVICON_DOWNLOAD_HELPER_H_
6 #define CHROME_BROWSER_FAVICON_FAVICON_DOWNLOAD_HELPER_H_
7
8 #include <vector>
9
10 #include "base/basictypes.h"
11 #include "base/memory/ref_counted.h"
12 #include "content/public/browser/web_contents_observer.h"
13
14 namespace content {
15 class WebContents;
16 }
17
18 namespace gfx {
19 class Image;
20 }
21
22 class GURL;
23 class FaviconDownloadHelperDelegate;
24 class SkBitmap;
25
26 // FaviconDownloadHelper handles requests to download favicons, and listens for
27 // the IPC messages from the renderer.
28 //
29 class FaviconDownloadHelper
30 : public content::WebContentsObserver,
31 public base::RefCounted<FaviconDownloadHelper> {
32
33 public:
34 static void CreateForWebContentsAndDelegate(
35 content::WebContents* contents,
36 FaviconDownloadHelperDelegate* delegate);
37
38 static FaviconDownloadHelper* FromWebContents(content::WebContents* contents);
39
40 // Download the favicon at |url|. Returns the unique id of the download
41 // request. The id will be passed to
42 // FaviconDownloadHelperDelegate::OnDidDownloadFavicon once the favicon has
43 // been retrieved.
44 int DownloadFavicon(const GURL& url, int image_size);
45
46 protected:
47 friend class base::RefCounted<FaviconDownloadHelper>;
48
49 FaviconDownloadHelper(content::WebContents* web_contents,
50 FaviconDownloadHelperDelegate* delegate);
51
52 virtual ~FaviconDownloadHelper();
53
54 // content::WebContentsObserver overrides.
55 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
56
57 // Message handler for IconHostMsg_DidDownloadFavicon. Called when the icon
58 // at |image_url| has been downloaded.
59 // |bitmaps| is a list of all the frames of the icon at |image_url|.
60 void OnDidDownloadFavicon(int id,
61 const GURL& image_url,
62 bool errored,
63 int requested_size,
64 const std::vector<SkBitmap>& bitmaps);
65
66 private:
67 // Delegate to pass Favicon bitmaps back to. Weak.
68 FaviconDownloadHelperDelegate* delegate_;
69 DISALLOW_COPY_AND_ASSIGN(FaviconDownloadHelper);
70 };
71
72 #endif // CHROME_BROWSER_FAVICON_FAVICON_DOWNLOAD_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698