| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_FAVICON_FAVICON_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_FAVICON_FAVICON_SERVICE_H_ |
| 6 #define CHROME_BROWSER_FAVICON_FAVICON_SERVICE_H_ | 6 #define CHROME_BROWSER_FAVICON_FAVICON_SERVICE_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 class FaviconService : public CancelableRequestProvider { | 24 class FaviconService : public CancelableRequestProvider { |
| 25 public: | 25 public: |
| 26 explicit FaviconService(Profile* profile); | 26 explicit FaviconService(Profile* profile); |
| 27 | 27 |
| 28 virtual ~FaviconService(); | 28 virtual ~FaviconService(); |
| 29 | 29 |
| 30 // Callback for GetFavicon. If we have previously inquired about the favicon | 30 // Callback for GetFavicon. If we have previously inquired about the favicon |
| 31 // for this URL, |know_favicon| will be true, and the rest of the fields will | 31 // for this URL, |know_favicon| will be true, and the rest of the fields will |
| 32 // be valid (otherwise they will be ignored). | 32 // be valid (otherwise they will be ignored). |
| 33 // | 33 // |
| 34 // On |know_favicon| == true, |data| will either contain the PNG encoded | 34 // On |know_favicon| == true, |icon_url_sizes| will be set to a mapping of |
| 35 // favicon data, or it will be NULL to indicate that the site does not have | 35 // all the favicons associated with the requested page to the sizes available |
| 36 // a favicon (in other words, we know the site doesn't have a favicon, as | 36 // at each icon url. |
| 37 // opposed to not knowing anything). |expired| will be set to true if we | 37 // Each entry in |elements| represents a favicon bitmap at a different pixel |
| 38 // refreshed the favicon "too long" ago and should be updated if the page | 38 // size. |
| 39 // is visited again. | 39 // |expired| will be set to true if we refreshed the favicon "too long" ago |
| 40 // and should be updated if the page is visited again. |
| 40 typedef base::Callback< | 41 typedef base::Callback< |
| 41 void(Handle, // handle | 42 void(Handle, // handle |
| 42 history::FaviconData)> // the type of favicon | 43 history::FaviconData)> // the type of favicon |
| 43 FaviconDataCallback; | 44 FaviconDataCallback; |
| 44 | 45 |
| 45 typedef CancelableRequest<FaviconDataCallback> GetFaviconRequest; | 46 typedef CancelableRequest<FaviconDataCallback> GetFaviconRequest; |
| 46 | 47 |
| 47 // Requests the |icon_type| of favicon. |consumer| is notified when the bits | 48 // Requests the |icon_type| of favicon. |consumer| is notified when the bits |
| 48 // have been fetched. |icon_url| is the URL of the icon itself, e.g. | 49 // have been fetched. |icon_url| is the URL of the icon itself, e.g. |
| 49 // <http://www.google.com/favicon.ico>. | 50 // <http://www.google.com/favicon.ico>. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 69 // priority of TOUCH_PRECOMPOSED_ICON, TOUCH_ICON and FAVICON. | 70 // priority of TOUCH_PRECOMPOSED_ICON, TOUCH_ICON and FAVICON. |
| 70 // | 71 // |
| 71 // Note: this version is intended to be used to retrieve the favicon of a | 72 // Note: this version is intended to be used to retrieve the favicon of a |
| 72 // page that has been browsed in the past. |expired| in the callback is | 73 // page that has been browsed in the past. |expired| in the callback is |
| 73 // always false. | 74 // always false. |
| 74 Handle GetFaviconForURL(const GURL& page_url, | 75 Handle GetFaviconForURL(const GURL& page_url, |
| 75 int icon_types, | 76 int icon_types, |
| 76 CancelableRequestConsumerBase* consumer, | 77 CancelableRequestConsumerBase* consumer, |
| 77 const FaviconDataCallback& callback); | 78 const FaviconDataCallback& callback); |
| 78 | 79 |
| 79 // Requests the favicon for |favicon_id|. The |consumer| is notified when the | |
| 80 // bits have been fetched. | |
| 81 Handle GetFaviconForID(history::FaviconID favicon_id, | |
| 82 CancelableRequestConsumerBase* consumer, | |
| 83 const FaviconDataCallback& callback); | |
| 84 | |
| 85 // Marks all types of favicon for the page as being out of date. | 80 // Marks all types of favicon for the page as being out of date. |
| 86 void SetFaviconOutOfDateForPage(const GURL& page_url); | 81 void SetFaviconOutOfDateForPage(const GURL& page_url); |
| 87 | 82 |
| 88 // Clones all icons from an existing page. This associates the icons from | 83 // Clones all icons from an existing page. This associates the icons from |
| 89 // |old_page_url| with |new_page_url|, provided |new_page_url| has no | 84 // |old_page_url| with |new_page_url|, provided |new_page_url| has no |
| 90 // recorded associations to any other icons. | 85 // recorded associations to any other icons. |
| 91 // Needed if you want to declare favicons (tentatively) in advance, before a | 86 // Needed if you want to declare favicons (tentatively) in advance, before a |
| 92 // page is ever visited. | 87 // page is ever visited. |
| 93 void CloneFavicon(const GURL& old_page_url, const GURL& new_page_url); | 88 void CloneFavicon(const GURL& old_page_url, const GURL& new_page_url); |
| 94 | 89 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 107 private: | 102 private: |
| 108 Profile* profile_; | 103 Profile* profile_; |
| 109 | 104 |
| 110 // Helper to forward an empty result if we cannot get the history service. | 105 // Helper to forward an empty result if we cannot get the history service. |
| 111 void ForwardEmptyResultAsync(GetFaviconRequest* request); | 106 void ForwardEmptyResultAsync(GetFaviconRequest* request); |
| 112 | 107 |
| 113 DISALLOW_COPY_AND_ASSIGN(FaviconService); | 108 DISALLOW_COPY_AND_ASSIGN(FaviconService); |
| 114 }; | 109 }; |
| 115 | 110 |
| 116 #endif // CHROME_BROWSER_FAVICON_FAVICON_SERVICE_H_ | 111 #endif // CHROME_BROWSER_FAVICON_FAVICON_SERVICE_H_ |
| OLD | NEW |