Chromium Code Reviews| 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 Callback6<Handle, // handle |
|
sky
2011/03/09 21:41:08
6 parameters with 2 booleans is pretty confusing.
michaelbai
2011/03/09 23:11:45
To be a structure makes a lot of code change. And
sky
2011/03/09 23:34:52
Is it really that many more code changes than you'
| |
| 42 bool, // know_favicon | 42 bool, // know_favicon |
| 43 scoped_refptr<RefCountedMemory>, // data | 43 scoped_refptr<RefCountedMemory>, // data |
| 44 bool, // expired | 44 bool, // expired |
| 45 GURL>::Type // url of the favicon | 45 GURL, // url of the favicon |
| 46 history::IconType>::Type // the type of favicon | |
| 46 FaviconDataCallback; | 47 FaviconDataCallback; |
| 47 | 48 |
| 48 typedef CancelableRequest<FaviconDataCallback> GetFaviconRequest; | 49 typedef CancelableRequest<FaviconDataCallback> GetFaviconRequest; |
| 49 | 50 |
| 50 // Requests the favicon. |consumer| is notified when the bits have been | 51 // Requests the |icon_type| of favicon. |consumer| is notified when the bits |
| 51 // fetched. | 52 // have been fetched. |
| 52 Handle GetFavicon(const GURL& icon_url, | 53 Handle GetFavicon(const GURL& icon_url, |
| 54 history::IconType icon_type, | |
| 53 CancelableRequestConsumerBase* consumer, | 55 CancelableRequestConsumerBase* consumer, |
| 54 FaviconDataCallback* callback); | 56 FaviconDataCallback* callback); |
| 55 | 57 |
| 56 // Fetches the favicon at |icon_url|, sending the results to the given | 58 // 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 | 59 // 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 | 60 // 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. | 61 // to |icon_url|. If the favicon has not been set, the database is not |
| 62 // updated. | |
| 60 Handle UpdateFaviconMappingAndFetch(const GURL& page_url, | 63 Handle UpdateFaviconMappingAndFetch(const GURL& page_url, |
| 61 const GURL& icon_url, | 64 const GURL& icon_url, |
| 65 history::IconType icon_type, | |
| 62 CancelableRequestConsumerBase* consumer, | 66 CancelableRequestConsumerBase* consumer, |
| 63 FaviconDataCallback* callback); | 67 FaviconDataCallback* callback); |
| 64 | 68 |
| 65 // Requests a favicon for a web page URL. |consumer| is notified | 69 // Requests any |icon_type| of favicon for a web page URL. |consumer| is |
| 66 // when the bits have been fetched. | 70 // notified when the bits have been fetched. |icon_type| could be any |
|
sky
2011/03/09 21:41:08
could->can
michaelbai
2011/03/09 23:11:45
Done.
| |
| 71 // combination of IconType value, but only one icon will be returned in the | |
| 72 // priority of TOUCH_PRECOMPOSED_ICON, TOUCH_ICON and FAV_ICON. | |
| 67 // | 73 // |
| 68 // Note: this version is intended to be used to retrieve the favicon of a | 74 // 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 | 75 // page that has been browsed in the past. |expired| in the callback is |
| 70 // always false. | 76 // always false. |
| 71 Handle GetFaviconForURL(const GURL& page_url, | 77 Handle GetFaviconForURL(const GURL& page_url, |
| 78 int icon_type, | |
|
sky
2011/03/09 21:41:08
icon_types.
michaelbai
2011/03/09 23:11:45
Done.
| |
| 72 CancelableRequestConsumerBase* consumer, | 79 CancelableRequestConsumerBase* consumer, |
| 73 FaviconDataCallback* callback); | 80 FaviconDataCallback* callback); |
| 74 | 81 |
| 75 // Marks the favicon for the page as being out of date. | 82 // Marks the all type of favicon for the page as being out of date. |
| 76 void SetFaviconOutOfDateForPage(const GURL& page_url); | 83 void SetFaviconOutOfDateForPage(const GURL& page_url); |
| 77 | 84 |
| 78 // Allows the importer to set many favicons for many pages at once. The pages | 85 // 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 | 86 // must exist, any favicon sets for unknown pages will be discarded. Existing |
| 80 // favicons will not be overwritten. | 87 // favicons will not be overwritten. |
| 81 void SetImportedFavicons( | 88 void SetImportedFavicons( |
| 82 const std::vector<history::ImportedFavIconUsage>& favicon_usage); | 89 const std::vector<history::ImportedFavIconUsage>& favicon_usage); |
| 83 | 90 |
| 84 // Sets the favicon for a page. | 91 // Sets the favicon for a page. |
| 85 void SetFavicon(const GURL& page_url, | 92 void SetFavicon(const GURL& page_url, |
| 86 const GURL& icon_url, | 93 const GURL& icon_url, |
| 87 const std::vector<unsigned char>& image_data); | 94 const std::vector<unsigned char>& image_data, |
| 95 history::IconType icon_type); | |
| 88 | 96 |
| 89 private: | 97 private: |
| 90 friend class base::RefCountedThreadSafe<FaviconService>; | 98 friend class base::RefCountedThreadSafe<FaviconService>; |
| 91 | 99 |
| 92 ~FaviconService(); | 100 ~FaviconService(); |
| 93 | 101 |
| 94 Profile* profile_; | 102 Profile* profile_; |
| 95 | 103 |
| 96 // Helper to forward an empty result if we cannot get the history service. | 104 // Helper to forward an empty result if we cannot get the history service. |
| 97 void ForwardEmptyResultAsync(GetFaviconRequest* request); | 105 void ForwardEmptyResultAsync(GetFaviconRequest* request); |
| 98 | 106 |
| 99 DISALLOW_COPY_AND_ASSIGN(FaviconService); | 107 DISALLOW_COPY_AND_ASSIGN(FaviconService); |
| 100 }; | 108 }; |
| 101 | 109 |
| 102 #endif // CHROME_BROWSER_FAVICON_SERVICE_H__ | 110 #endif // CHROME_BROWSER_FAVICON_SERVICE_H__ |
| OLD | NEW |