Chromium Code Reviews| 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 "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> { | |
|
joth
2012/10/18 21:51:13
does this need to be ref-counted? seems overkill i
| |
| 32 | |
| 33 public: | |
| 34 static void CreateForWebContentsAndDelegate( | |
|
joth
2012/10/18 21:51:13
nit: I think the AndDelegate is spurious here, and
| |
| 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. | |
|
joth
2012/10/18 21:51:13
could mention what |image_size| is. (is it a _max_
Cait (Slow)
2012/10/23 21:36:43
Added a description of image_size. It most likely
| |
| 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); | |
|
joth
2012/10/18 21:51:13
think this can be DISALLOW_IMPLICIT_CONSTRUCTORS
Cait (Slow)
2012/10/23 21:36:43
Done.
| |
| 70 }; | |
| 71 | |
| 72 #endif // CHROME_BROWSER_FAVICON_FAVICON_DOWNLOAD_HELPER_H_ | |
| OLD | NEW |