OLD | NEW |
---|---|
(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 | |
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. | |
joth
2012/10/30 14:41:45
perhaps also mention these instances are owned by
Cait (Slow)
2012/10/30 20:07:33
Done.
| |
26 | |
27 class FaviconHelper : public content::RenderViewObserver { | |
28 public: | |
29 explicit FaviconHelper(content::RenderView* render_view); | |
30 virtual ~FaviconHelper(); | |
joth
2012/10/30 14:41:45
d'tor can be private. (It gets deleted via OnDestr
Cait (Slow)
2012/10/30 20:07:33
Done.
| |
31 | |
32 // Send a message to update the favicon URL for a page. | |
33 void SendUpdateFaviconURL(int32 routing_id, | |
34 int32 page_id, | |
35 const std::vector<FaviconURL>& urls); | |
36 | |
37 private: | |
38 // This callback is triggered when DownloadFavicon completes, either | |
39 // succesfully or with a failure. See DownloadFavicon for more | |
40 // details. | |
41 void DidDownloadFavicon( | |
42 int requested_size, | |
43 webkit_glue::MultiResolutionImageResourceFetcher* fetcher, | |
44 const std::vector<SkBitmap>& images); | |
45 | |
46 // Requests to download a favicon image. When done, the RenderView | |
47 // is notified by way of DidDownloadFavicon. Returns true if the | |
48 // request was successfully started, false otherwise. id is used to | |
49 // uniquely identify the request and passed back to the | |
50 // DidDownloadFavicon method. If the image has multiple frames, the | |
51 // frame whose size is image_size is returned. If the image doesn't | |
52 // have a frame at the specified size, the first is returned. | |
53 bool DownloadFavicon(int id, const GURL& image_url, int image_size); | |
54 | |
55 // Decodes a data: URL image or returns an empty image in case of failure. | |
56 SkBitmap ImageFromDataUrl(const GURL&) const; | |
57 | |
58 // Message handler. | |
59 void OnDownloadFavicon(int id, const GURL& image_url, int image_size); | |
60 | |
61 // RenderViewObserver implementation. | |
62 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | |
63 | |
64 typedef ScopedVector<webkit_glue::MultiResolutionImageResourceFetcher> | |
65 ImageResourceFetcherList; | |
66 | |
67 // ImageResourceFetchers schedule via DownloadImage. | |
68 ImageResourceFetcherList image_fetchers_; | |
69 | |
70 DISALLOW_COPY_AND_ASSIGN(FaviconHelper); | |
71 }; | |
72 | |
73 #endif // CHROME_RENDERER_FAVICON_HELPER_H_ | |
OLD | NEW |