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