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

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..b3e76656b06b1a896b43b0131a897775ac201af9
--- /dev/null
+++ b/chrome/browser/favicon/favicon_download_helper.h
@@ -0,0 +1,61 @@
+// 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/callback.h"
+#include "chrome/common/favicon_url.h"
Jói 2012/10/16 21:56:52 Is favicon_url.h free of other dependencies? Once
Cait (Slow) 2012/10/17 16:00:42 Agree. Looking into breaking the remaining DEPS fo
+#include "content/public/browser/web_contents_observer.h"
+#include "content/public/browser/web_contents_user_data.h"
+
+namespace gfx {
+class Image;
+}
+
+class GURL;
+class FaviconDownloadDelegate;
+class SkBitmap;
+
+// FaviconDownloadHelper handles requests to download favicons, and listens for
+// the IPC messages from the renderer.
+//
+class FaviconDownloadHelper : public content::WebContentsObserver,
Jói 2012/10/16 21:56:52 indent like this class FaviconDownloadHelper
Cait (Slow) 2012/10/17 16:00:42 Done.
+ public content::WebContentsUserData<FaviconDownloadHelper> {
+ public:
+ virtual ~FaviconDownloadHelper();
+
+ // Download the favicon at |url|.
+ int DownloadFavicon(const GURL& url, int image_size);
Jói 2012/10/16 21:56:52 Need to document the return value is the 'id' you
Cait (Slow) 2012/10/17 16:00:42 Done.
+
+ // Set our external delegate.
+ void SetExternalDelegate(FaviconDownloadDelegate* delegate) {
+ external_delegate_ = delegate;
+ }
+
+ // content::WebContentsObserver overrides.
+ virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
Jói 2012/10/16 21:56:52 I think this can be protected; likewise OnDidDownl
Cait (Slow) 2012/10/17 16:00:42 Done.
+
+ // 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);
+
+ // Delegate to pass Favicon bitmaps back to. Weak.
+ FaviconDownloadDelegate* external_delegate_;
Jói 2012/10/16 21:56:52 Should be private. Can name it just delegate_.
Cait (Slow) 2012/10/17 16:00:42 Done.
+
+ private:
+ explicit FaviconDownloadHelper(content::WebContents* web_contents);
Jói 2012/10/16 21:56:52 You could follow the example of AutofillManager::C
Cait (Slow) 2012/10/17 16:00:42 Done.
+ friend class content::WebContentsUserData<FaviconDownloadHelper>;
+ DISALLOW_COPY_AND_ASSIGN(FaviconDownloadHelper);
+};
+
+#endif // CHROME_BROWSER_FAVICON_FAVICON_DOWNLOAD_HELPER_H_

Powered by Google App Engine
This is Rietveld 408576698