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

Side by Side Diff: chrome/renderer/favicon_helper.h

Issue 11232068: Extract renderer-side favicon downloading code into separate helper class (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move remaining favicon functionality to FaviconHelper Created 8 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 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_RENDERER_FAVICON_HELPER_H_
6 #define CHROME_RENDERER_FAVICON_HELPER_H_
7
8 #include <string>
9 #include <vector>
10
joth 2012/10/30 20:22:57 nit: remove \n here and line 26
Cait (Slow) 2012/10/30 21:39:40 Done.
11
12 #include "base/memory/linked_ptr.h"
13 #include "base/memory/scoped_vector.h"
14 #include "content/public/renderer/render_view_observer.h"
15 #include "googleurl/src/gurl.h"
16
17 struct FaviconURL;
18 class SkBitmap;
19
20 namespace webkit_glue {
21 class MultiResolutionImageResourceFetcher;
22 }
23
24 // This class deals with favicon downloading.
25 // There is one FaviconHelper per RenderView, which is owned by the RenderView.
26
27 class FaviconHelper : public content::RenderViewObserver {
28 public:
29 explicit FaviconHelper(content::RenderView* render_view);
30
31 // Send a message to update the favicon URL for a page.
32 void SendUpdateFaviconURL(int32 routing_id,
33 int32 page_id,
34 const std::vector<FaviconURL>& urls);
35
36 private:
37 virtual ~FaviconHelper();
38
39 // This callback is triggered when DownloadFavicon completes, either
40 // succesfully or with a failure. See DownloadFavicon for more
41 // details.
42 void DidDownloadFavicon(
43 int requested_size,
44 webkit_glue::MultiResolutionImageResourceFetcher* fetcher,
45 const std::vector<SkBitmap>& images);
46
47 // Requests to download a favicon image. When done, the RenderView
48 // is notified by way of DidDownloadFavicon. Returns true if the
49 // request was successfully started, false otherwise. id is used to
50 // uniquely identify the request and passed back to the
51 // DidDownloadFavicon method. If the image has multiple frames, the
52 // frame whose size is image_size is returned. If the image doesn't
53 // have a frame at the specified size, the first is returned.
54 bool DownloadFavicon(int id, const GURL& image_url, int image_size);
55
56 // Decodes a data: URL image or returns an empty image in case of failure.
57 SkBitmap ImageFromDataUrl(const GURL&) const;
58
59 // Message handler.
60 void OnDownloadFavicon(int id, const GURL& image_url, int image_size);
61
62 // RenderViewObserver implementation.
63 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
64 virtual void DidStopLoading() OVERRIDE;
65 virtual void DidChangeIcon(WebKit::WebFrame* frame,
66 WebKit::WebIconURL::Type icon_type) OVERRIDE;
67
68 typedef ScopedVector<webkit_glue::MultiResolutionImageResourceFetcher>
69 ImageResourceFetcherList;
70
71 // ImageResourceFetchers schedule via DownloadImage.
72 ImageResourceFetcherList image_fetchers_;
73
74 DISALLOW_COPY_AND_ASSIGN(FaviconHelper);
75 };
76
77 #endif // CHROME_RENDERER_FAVICON_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698