Chromium Code Reviews| Index: chrome/browser/favicon/favicon_download_helper.h |
| diff --git a/chrome/browser/favicon/favicon_download_helper.h b/chrome/browser/favicon/favicon_download_helper.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..0bc6120158718c8dd50647022a377b69b8b33de3 |
| --- /dev/null |
| +++ b/chrome/browser/favicon/favicon_download_helper.h |
| @@ -0,0 +1,72 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_FAVICON_FAVICON_DOWNLOAD_HELPER_H_ |
| +#define CHROME_BROWSER_FAVICON_FAVICON_DOWNLOAD_HELPER_H_ |
| + |
| +#include <vector> |
| + |
| +#include "base/basictypes.h" |
| +#include "base/memory/ref_counted.h" |
| +#include "content/public/browser/web_contents_observer.h" |
| + |
| +namespace content { |
| +class WebContents; |
| +} |
| + |
| +namespace gfx { |
| +class Image; |
| +} |
| + |
| +class GURL; |
| +class FaviconDownloadHelperDelegate; |
| +class SkBitmap; |
| + |
| +// FaviconDownloadHelper handles requests to download favicons, and listens for |
| +// the IPC messages from the renderer. |
| +// |
| +class FaviconDownloadHelper |
| + : public content::WebContentsObserver, |
| + public base::RefCounted<FaviconDownloadHelper> { |
|
joth
2012/10/18 21:51:13
does this need to be ref-counted? seems overkill i
|
| + |
| + public: |
| + static void CreateForWebContentsAndDelegate( |
|
joth
2012/10/18 21:51:13
nit: I think the AndDelegate is spurious here, and
|
| + content::WebContents* contents, |
| + FaviconDownloadHelperDelegate* delegate); |
| + |
| + static FaviconDownloadHelper* FromWebContents(content::WebContents* contents); |
| + |
| + // Download the favicon at |url|. Returns the unique id of the download |
| + // request. The id will be passed to |
| + // FaviconDownloadHelperDelegate::OnDidDownloadFavicon once the favicon has |
| + // 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
|
| + int DownloadFavicon(const GURL& url, int image_size); |
| + |
| + protected: |
| + friend class base::RefCounted<FaviconDownloadHelper>; |
| + |
| + FaviconDownloadHelper(content::WebContents* web_contents, |
| + FaviconDownloadHelperDelegate* delegate); |
| + |
| + virtual ~FaviconDownloadHelper(); |
| + |
| + // content::WebContentsObserver overrides. |
| + virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| + |
| + // Message handler for IconHostMsg_DidDownloadFavicon. Called when the icon |
| + // at |image_url| has been downloaded. |
| + // |bitmaps| is a list of all the frames of the icon at |image_url|. |
| + void OnDidDownloadFavicon(int id, |
| + const GURL& image_url, |
| + bool errored, |
| + int requested_size, |
| + const std::vector<SkBitmap>& bitmaps); |
| + |
| + private: |
| + // Delegate to pass Favicon bitmaps back to. Weak. |
| + FaviconDownloadHelperDelegate* delegate_; |
| + 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.
|
| +}; |
| + |
| +#endif // CHROME_BROWSER_FAVICON_FAVICON_DOWNLOAD_HELPER_H_ |