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

Unified 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: 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 side-by-side diff with in-line comments
Download patch
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..979636df25b45b0b736b4d5783be6bbd32753761
--- /dev/null
+++ b/chrome/browser/favicon/favicon_download_helper.h
@@ -0,0 +1,80 @@
+// 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 "chrome/common/favicon_url.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.
+//
sky 2012/10/29 23:12:48 nit: remove empty line.
Cait (Slow) 2012/10/30 18:05:55 Done.
+class FaviconDownloadHelper
+ : public content::WebContentsObserver,
+ 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.
+
sky 2012/10/29 23:12:48 nit: remove newline.
Cait (Slow) 2012/10/30 18:05:55 Done.
+ public:
+ static void CreateForWebContentsAndDelegate(
+ 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.
+ // Note that |image_size| is a hint for images with multiple sizes. The
+ // downloaded image is not resized to the given image_size. If 0 is passed,
+ // the first frame of the image is returned.
+ 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);
+
+ // Message Handler.
+ void OnUpdateFaviconURL(int32 page_id,
+ const std::vector<FaviconURL>& candidates);
+
+ private:
+ // Delegate to pass Favicon bitmaps back to. Weak.
+ FaviconDownloadHelperDelegate* delegate_;
+ 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.
+};
+
+#endif // CHROME_BROWSER_FAVICON_FAVICON_DOWNLOAD_HELPER_H_

Powered by Google App Engine
This is Rietveld 408576698