OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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_SERVICE_H__ | 5 #ifndef CHROME_BROWSER_FAVICON_SERVICE_H__ |
6 #define CHROME_BROWSER_FAVICON_SERVICE_H__ | 6 #define CHROME_BROWSER_FAVICON_SERVICE_H__ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 20 matching lines...) Expand all Loading... | |
31 // Callback for GetFavicon. If we have previously inquired about the favicon | 31 // Callback for GetFavicon. If we have previously inquired about the favicon |
32 // for this URL, |know_favicon| will be true, and the rest of the fields will | 32 // for this URL, |know_favicon| will be true, and the rest of the fields will |
33 // be valid (otherwise they will be ignored). | 33 // be valid (otherwise they will be ignored). |
34 // | 34 // |
35 // On |know_favicon| == true, |data| will either contain the PNG encoded | 35 // On |know_favicon| == true, |data| will either contain the PNG encoded |
36 // favicon data, or it will be NULL to indicate that the site does not have | 36 // favicon data, or it will be NULL to indicate that the site does not have |
37 // a favicon (in other words, we know the site doesn't have a favicon, as | 37 // a favicon (in other words, we know the site doesn't have a favicon, as |
38 // opposed to not knowing anything). |expired| will be set to true if we | 38 // opposed to not knowing anything). |expired| will be set to true if we |
39 // refreshed the favicon "too long" ago and should be updated if the page | 39 // refreshed the favicon "too long" ago and should be updated if the page |
40 // is visited again. | 40 // is visited again. |
41 typedef Callback5<Handle, // handle | 41 typedef Callback2<Handle, // handle |
42 bool, // know_favicon | 42 history::FaviconData>::Type // the type of favicon |
43 scoped_refptr<RefCountedMemory>, // data | |
44 bool, // expired | |
45 GURL>::Type // url of the favicon | |
46 FaviconDataCallback; | 43 FaviconDataCallback; |
47 | 44 |
48 typedef CancelableRequest<FaviconDataCallback> GetFaviconRequest; | 45 typedef CancelableRequest<FaviconDataCallback> GetFaviconRequest; |
49 | 46 |
50 // Requests the favicon. |consumer| is notified when the bits have been | 47 // Requests the |icon_type| of favicon. |consumer| is notified when the bits |
51 // fetched. | 48 // have been fetched. |
52 Handle GetFavicon(const GURL& icon_url, | 49 Handle GetFavicon(const GURL& icon_url, |
50 history::IconType icon_type, | |
53 CancelableRequestConsumerBase* consumer, | 51 CancelableRequestConsumerBase* consumer, |
54 FaviconDataCallback* callback); | 52 FaviconDataCallback* callback); |
55 | 53 |
56 // Fetches the favicon at |icon_url|, sending the results to the given | 54 // Fetches the |icon_type| of favicon at |icon_url|, sending the results to |
57 // |callback|. If the favicon has previously been set via SetFavicon(), then | 55 // the given |callback|. If the favicon has previously been set via |
58 // the favicon URL for |page_url| and all redirects is set to |icon_url|. If | 56 // SetFavicon(), then the favicon URL for |page_url| and all redirects is set |
59 // the favicon has not been set, the database is not updated. | 57 // to |icon_url|. If the favicon has not been set, the database is not |
58 // updated. | |
60 Handle UpdateFaviconMappingAndFetch(const GURL& page_url, | 59 Handle UpdateFaviconMappingAndFetch(const GURL& page_url, |
61 const GURL& icon_url, | 60 const GURL& icon_url, |
61 history::IconType icon_type, | |
62 CancelableRequestConsumerBase* consumer, | 62 CancelableRequestConsumerBase* consumer, |
63 FaviconDataCallback* callback); | 63 FaviconDataCallback* callback); |
64 | 64 |
65 // Requests a favicon for a web page URL. |consumer| is notified | 65 // Requests any |icon_type| of favicon for a web page URL. |consumer| is |
sky
2011/03/11 17:56:45
icon_types
| |
66 // when the bits have been fetched. | 66 // notified when the bits have been fetched. |icon_type| can be any |
sky
2011/03/11 17:56:45
icon_types
| |
67 // combination of IconType value, but only one icon will be returned in the | |
68 // priority of TOUCH_PRECOMPOSED_ICON, TOUCH_ICON and FAV_ICON. | |
67 // | 69 // |
68 // Note: this version is intended to be used to retrieve the favicon of a | 70 // Note: this version is intended to be used to retrieve the favicon of a |
69 // page that has been browsed in the past. |expired| in the callback is | 71 // page that has been browsed in the past. |expired| in the callback is |
70 // always false. | 72 // always false. |
71 Handle GetFaviconForURL(const GURL& page_url, | 73 Handle GetFaviconForURL(const GURL& page_url, |
74 int icon_types, | |
72 CancelableRequestConsumerBase* consumer, | 75 CancelableRequestConsumerBase* consumer, |
73 FaviconDataCallback* callback); | 76 FaviconDataCallback* callback); |
74 | 77 |
75 // Marks the favicon for the page as being out of date. | 78 // Marks all type of favicon for the page as being out of date. |
sky
2011/03/11 17:56:45
all types of favicons
| |
76 void SetFaviconOutOfDateForPage(const GURL& page_url); | 79 void SetFaviconOutOfDateForPage(const GURL& page_url); |
77 | 80 |
78 // Allows the importer to set many favicons for many pages at once. The pages | 81 // Allows the importer to set many favicons for many pages at once. The pages |
79 // must exist, any favicon sets for unknown pages will be discarded. Existing | 82 // must exist, any favicon sets for unknown pages will be discarded. Existing |
80 // favicons will not be overwritten. | 83 // favicons will not be overwritten. |
81 void SetImportedFavicons( | 84 void SetImportedFavicons( |
82 const std::vector<history::ImportedFavIconUsage>& favicon_usage); | 85 const std::vector<history::ImportedFavIconUsage>& favicon_usage); |
83 | 86 |
84 // Sets the favicon for a page. | 87 // Sets the favicon for a page. |
85 void SetFavicon(const GURL& page_url, | 88 void SetFavicon(const GURL& page_url, |
86 const GURL& icon_url, | 89 const GURL& icon_url, |
87 const std::vector<unsigned char>& image_data); | 90 const std::vector<unsigned char>& image_data, |
91 history::IconType icon_type); | |
88 | 92 |
89 private: | 93 private: |
90 friend class base::RefCountedThreadSafe<FaviconService>; | 94 friend class base::RefCountedThreadSafe<FaviconService>; |
91 | 95 |
92 ~FaviconService(); | 96 ~FaviconService(); |
93 | 97 |
94 Profile* profile_; | 98 Profile* profile_; |
95 | 99 |
96 // Helper to forward an empty result if we cannot get the history service. | 100 // Helper to forward an empty result if we cannot get the history service. |
97 void ForwardEmptyResultAsync(GetFaviconRequest* request); | 101 void ForwardEmptyResultAsync(GetFaviconRequest* request); |
98 | 102 |
99 DISALLOW_COPY_AND_ASSIGN(FaviconService); | 103 DISALLOW_COPY_AND_ASSIGN(FaviconService); |
100 }; | 104 }; |
101 | 105 |
102 #endif // CHROME_BROWSER_FAVICON_SERVICE_H__ | 106 #endif // CHROME_BROWSER_FAVICON_SERVICE_H__ |
OLD | NEW |