OLD | NEW |
---|---|
(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 "chrome/common/favicon_url.h" | |
13 #include "content/public/browser/web_contents_observer.h" | |
14 | |
15 namespace content { | |
16 class WebContents; | |
17 } | |
18 | |
19 namespace gfx { | |
20 class Image; | |
21 } | |
22 | |
23 class GURL; | |
24 class FaviconDownloadHelperDelegate; | |
25 class SkBitmap; | |
26 | |
27 // FaviconDownloadHelper handles requests to download favicons, and listens for | |
28 // the IPC messages from the renderer. | |
29 // | |
sky
2012/10/29 23:12:48
nit: remove empty line.
Cait (Slow)
2012/10/30 18:05:55
Done.
| |
30 class FaviconDownloadHelper | |
31 : public content::WebContentsObserver, | |
32 public base::RefCounted<FaviconDownloadHelper> { | |
sky
2012/10/29 23:12:48
Why is this ref counted? Doing so makes it all too
Cait (Slow)
2012/10/30 18:05:55
Done.
| |
33 | |
sky
2012/10/29 23:12:48
nit: remove newline.
Cait (Slow)
2012/10/30 18:05:55
Done.
| |
34 public: | |
35 static void CreateForWebContentsAndDelegate( | |
36 content::WebContents* contents, | |
37 FaviconDownloadHelperDelegate* delegate); | |
38 | |
39 static FaviconDownloadHelper* FromWebContents(content::WebContents* contents); | |
40 | |
41 // Download the favicon at |url|. Returns the unique id of the download | |
42 // request. The id will be passed to | |
43 // FaviconDownloadHelperDelegate::OnDidDownloadFavicon once the favicon has | |
44 // been retrieved. | |
45 // Note that |image_size| is a hint for images with multiple sizes. The | |
46 // downloaded image is not resized to the given image_size. If 0 is passed, | |
47 // the first frame of the image is returned. | |
48 int DownloadFavicon(const GURL& url, int image_size); | |
49 | |
50 protected: | |
51 friend class base::RefCounted<FaviconDownloadHelper>; | |
52 | |
53 FaviconDownloadHelper(content::WebContents* web_contents, | |
54 FaviconDownloadHelperDelegate* delegate); | |
55 | |
56 virtual ~FaviconDownloadHelper(); | |
57 | |
58 // content::WebContentsObserver overrides. | |
59 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | |
60 | |
61 // Message handler for IconHostMsg_DidDownloadFavicon. Called when the icon | |
62 // at |image_url| has been downloaded. | |
63 // |bitmaps| is a list of all the frames of the icon at |image_url|. | |
64 void OnDidDownloadFavicon(int id, | |
65 const GURL& image_url, | |
66 bool errored, | |
67 int requested_size, | |
68 const std::vector<SkBitmap>& bitmaps); | |
69 | |
70 // Message Handler. | |
71 void OnUpdateFaviconURL(int32 page_id, | |
72 const std::vector<FaviconURL>& candidates); | |
73 | |
74 private: | |
75 // Delegate to pass Favicon bitmaps back to. Weak. | |
76 FaviconDownloadHelperDelegate* delegate_; | |
77 DISALLOW_IMPLICIT_CONSTRUCTORS(FaviconDownloadHelper); | |
sky
2012/10/29 23:12:48
nit: newline between 76/77.
Cait (Slow)
2012/10/30 18:05:55
Done.
| |
78 }; | |
79 | |
80 #endif // CHROME_BROWSER_FAVICON_FAVICON_DOWNLOAD_HELPER_H_ | |
OLD | NEW |