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 // |know_favicon| will be true, and |icon_url_sizes| will be empty if we know |
38 // refreshed the favicon "too long" ago and should be updated if the page | 38 // that the site does not have a favicon. |
39 // is visited again. | 39 // Each entry in |elements| represents a favicon bitmap at a different pixel |
| 40 // size. If a |pixel_size| parameter was passed in order to get the favicon |
| 41 // data, |elements| will have a single entry with the best match for |
| 42 // |pixel_size|. |
| 43 // |expired| will be set to true if we refreshed the favicon "too long" ago |
| 44 // and should be updated if the page is visited again. |
40 typedef base::Callback< | 45 typedef base::Callback< |
41 void(Handle, // handle | 46 void(Handle, // handle |
42 history::FaviconData)> // the type of favicon | 47 history::FaviconData)> // the type of favicon |
43 FaviconDataCallback; | 48 FaviconDataCallback; |
44 | 49 |
45 typedef CancelableRequest<FaviconDataCallback> GetFaviconRequest; | 50 typedef CancelableRequest<FaviconDataCallback> GetFaviconRequest; |
46 | 51 |
47 // Requests the |icon_type| of favicon. |consumer| is notified when the bits | 52 // 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. | 53 // have been fetched. |icon_url| is the URL of the icon itself, e.g. |
49 // <http://www.google.com/favicon.ico>. | 54 // <http://www.google.com/favicon.ico>. |
(...skipping 19 matching lines...) Expand all Loading... |
69 // priority of TOUCH_PRECOMPOSED_ICON, TOUCH_ICON and FAVICON. | 74 // priority of TOUCH_PRECOMPOSED_ICON, TOUCH_ICON and FAVICON. |
70 // | 75 // |
71 // Note: this version is intended to be used to retrieve the favicon of a | 76 // 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 | 77 // page that has been browsed in the past. |expired| in the callback is |
73 // always false. | 78 // always false. |
74 Handle GetFaviconForURL(const GURL& page_url, | 79 Handle GetFaviconForURL(const GURL& page_url, |
75 int icon_types, | 80 int icon_types, |
76 CancelableRequestConsumerBase* consumer, | 81 CancelableRequestConsumerBase* consumer, |
77 const FaviconDataCallback& callback); | 82 const FaviconDataCallback& callback); |
78 | 83 |
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. | 84 // Marks all types of favicon for the page as being out of date. |
86 void SetFaviconOutOfDateForPage(const GURL& page_url); | 85 void SetFaviconOutOfDateForPage(const GURL& page_url); |
87 | 86 |
88 // Clones all icons from an existing page. This associates the icons from | 87 // 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 | 88 // |old_page_url| with |new_page_url|, provided |new_page_url| has no |
90 // recorded associations to any other icons. | 89 // recorded associations to any other icons. |
91 // Needed if you want to declare favicons (tentatively) in advance, before a | 90 // Needed if you want to declare favicons (tentatively) in advance, before a |
92 // page is ever visited. | 91 // page is ever visited. |
93 void CloneFavicon(const GURL& old_page_url, const GURL& new_page_url); | 92 void CloneFavicon(const GURL& old_page_url, const GURL& new_page_url); |
94 | 93 |
(...skipping 12 matching lines...) Expand all Loading... |
107 private: | 106 private: |
108 Profile* profile_; | 107 Profile* profile_; |
109 | 108 |
110 // Helper to forward an empty result if we cannot get the history service. | 109 // Helper to forward an empty result if we cannot get the history service. |
111 void ForwardEmptyResultAsync(GetFaviconRequest* request); | 110 void ForwardEmptyResultAsync(GetFaviconRequest* request); |
112 | 111 |
113 DISALLOW_COPY_AND_ASSIGN(FaviconService); | 112 DISALLOW_COPY_AND_ASSIGN(FaviconService); |
114 }; | 113 }; |
115 | 114 |
116 #endif // CHROME_BROWSER_FAVICON_FAVICON_SERVICE_H_ | 115 #endif // CHROME_BROWSER_FAVICON_FAVICON_SERVICE_H_ |
OLD | NEW |