| 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 private: | |
| 30 virtual ~FaviconHelper(); | |
| 31 | |
| 32 // Message handler. | |
| 33 void OnDownloadFavicon(int id, const GURL& image_url, int image_size); | |
| 34 | |
| 35 // Requests to download a favicon image. When done, the RenderView | |
| 36 // is notified by way of DidDownloadFavicon. Returns true if the | |
| 37 // request was successfully started, false otherwise. id is used to | |
| 38 // uniquely identify the request and passed back to the | |
| 39 // DidDownloadFavicon method. If the image has multiple frames, the | |
| 40 // frame whose size is image_size is returned. If the image doesn't | |
| 41 // have a frame at the specified size, the first is returned. | |
| 42 bool DownloadFavicon(int id, const GURL& image_url, int image_size); | |
| 43 | |
| 44 // This callback is triggered when DownloadFavicon completes, either | |
| 45 // succesfully or with a failure. See DownloadFavicon for more | |
| 46 // details. | |
| 47 void DidDownloadFavicon( | |
| 48 int requested_size, | |
| 49 webkit_glue::MultiResolutionImageResourceFetcher* fetcher, | |
| 50 const std::vector<SkBitmap>& images); | |
| 51 | |
| 52 // Decodes a data: URL image or returns an empty image in case of failure. | |
| 53 SkBitmap ImageFromDataUrl(const GURL&) const; | |
| 54 | |
| 55 // Send a message to update the favicon URL for a page. | |
| 56 void SendUpdateFaviconURL(int32 routing_id, | |
| 57 int32 page_id, | |
| 58 const std::vector<FaviconURL>& urls); | |
| 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 |