| OLD | NEW |
| 1 // Copyright (c) 2017 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2017 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 COMPONENTS_FAVICON_CORE_FAVICON_SERVICE_H_ | 5 #ifndef COMPONENTS_FAVICON_CORE_FAVICON_SERVICE_H_ |
| 6 #define COMPONENTS_FAVICON_CORE_FAVICON_SERVICE_H_ | 6 #define COMPONENTS_FAVICON_CORE_FAVICON_SERVICE_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 // the largest favicon bitmap is returned. | 51 // the largest favicon bitmap is returned. |
| 52 virtual base::CancelableTaskTracker::TaskId GetRawFavicon( | 52 virtual base::CancelableTaskTracker::TaskId GetRawFavicon( |
| 53 const GURL& icon_url, | 53 const GURL& icon_url, |
| 54 favicon_base::IconType icon_type, | 54 favicon_base::IconType icon_type, |
| 55 int desired_size_in_pixel, | 55 int desired_size_in_pixel, |
| 56 const favicon_base::FaviconRawBitmapCallback& callback, | 56 const favicon_base::FaviconRawBitmapCallback& callback, |
| 57 base::CancelableTaskTracker* tracker) = 0; | 57 base::CancelableTaskTracker* tracker) = 0; |
| 58 | 58 |
| 59 // The first argument for |callback| is the set of bitmaps for the passed in | 59 // The first argument for |callback| is the set of bitmaps for the passed in |
| 60 // URL and icon types whose pixel sizes best match the passed in | 60 // URL and icon types whose pixel sizes best match the passed in |
| 61 // |desired_size_in_dip| at the resource scale factors supported by the | 61 // |desired_sizes_in_pixel| The vector has at most one result for each of the |
| 62 // current platform (eg MacOS) in addition to 1x. The vector has at most one | 62 // desired sizes. There are less entries if a single/ result is the best |
| 63 // result for each of the resource scale factors. There are less entries if a | 63 // bitmap to use for several desired sizes. |
| 64 // single/ result is the best bitmap to use for several resource scale | |
| 65 // factors. | |
| 66 virtual base::CancelableTaskTracker::TaskId GetFavicon( | 64 virtual base::CancelableTaskTracker::TaskId GetFavicon( |
| 67 const GURL& icon_url, | 65 const GURL& icon_url, |
| 68 favicon_base::IconType icon_type, | 66 favicon_base::IconType icon_type, |
| 69 int desired_size_in_dip, | 67 const std::vector<int>& desired_sizes_in_pixel, |
| 70 const favicon_base::FaviconResultsCallback& callback, | 68 const favicon_base::FaviconResultsCallback& callback, |
| 71 base::CancelableTaskTracker* tracker) = 0; | 69 base::CancelableTaskTracker* tracker) = 0; |
| 72 | 70 |
| 73 ////////////////////////////////////////////////////////////////////////////// | 71 ////////////////////////////////////////////////////////////////////////////// |
| 74 // Methods to request favicon bitmaps from the history backend for |page_url|. | 72 // Methods to request favicon bitmaps from the history backend for |page_url|. |
| 75 // |page_url| is the web page the favicon is associated with. | 73 // |page_url| is the web page the favicon is associated with. |
| 76 // (e.g. <http://www.google.com>) | 74 // (e.g. <http://www.google.com>) |
| 77 | 75 |
| 78 // Requests the favicon for the page at |page_url| of type | 76 // Requests the favicon for the page at |page_url| of type |
| 79 // favicon_base::FAVICON and of size gfx::kFaviconSize. The returned | 77 // favicon_base::FAVICON and of size gfx::kFaviconSize. The returned |
| (...skipping 26 matching lines...) Expand all Loading... |
| 106 virtual base::CancelableTaskTracker::TaskId GetLargestRawFaviconForPageURL( | 104 virtual base::CancelableTaskTracker::TaskId GetLargestRawFaviconForPageURL( |
| 107 const GURL& page_url, | 105 const GURL& page_url, |
| 108 const std::vector<int>& icon_types, | 106 const std::vector<int>& icon_types, |
| 109 int minimum_size_in_pixels, | 107 int minimum_size_in_pixels, |
| 110 const favicon_base::FaviconRawBitmapCallback& callback, | 108 const favicon_base::FaviconRawBitmapCallback& callback, |
| 111 base::CancelableTaskTracker* tracker) = 0; | 109 base::CancelableTaskTracker* tracker) = 0; |
| 112 | 110 |
| 113 virtual base::CancelableTaskTracker::TaskId GetFaviconForPageURL( | 111 virtual base::CancelableTaskTracker::TaskId GetFaviconForPageURL( |
| 114 const GURL& page_url, | 112 const GURL& page_url, |
| 115 int icon_types, | 113 int icon_types, |
| 116 int desired_size_in_dip, | 114 const std::vector<int>& desired_sizes_in_pixel, |
| 117 const favicon_base::FaviconResultsCallback& callback, | 115 const favicon_base::FaviconResultsCallback& callback, |
| 118 base::CancelableTaskTracker* tracker) = 0; | 116 base::CancelableTaskTracker* tracker) = 0; |
| 119 | 117 |
| 120 // Set the favicon mappings to |page_url| for |icon_types| in the history | 118 // Set the favicon mappings to |page_url| for |icon_types| in the history |
| 121 // database. | 119 // database. |
| 122 // Sample |icon_urls|: | 120 // Sample |icon_urls|: |
| 123 // { ICON_URL1 -> TOUCH_ICON, known to the database, | 121 // { ICON_URL1 -> TOUCH_ICON, known to the database, |
| 124 // ICON_URL2 -> TOUCH_ICON, not known to the database, | 122 // ICON_URL2 -> TOUCH_ICON, not known to the database, |
| 125 // ICON_URL3 -> TOUCH_PRECOMPOSED_ICON, known to the database } | 123 // ICON_URL3 -> TOUCH_PRECOMPOSED_ICON, known to the database } |
| 126 // The new mappings are computed from |icon_urls| with these rules: | 124 // The new mappings are computed from |icon_urls| with these rules: |
| 127 // 1) Any urls in |icon_urls| which are not already known to the database are | 125 // 1) Any urls in |icon_urls| which are not already known to the database are |
| 128 // rejected. | 126 // rejected. |
| 129 // Sample new mappings to |page_url|: { ICON_URL1, ICON_URL3 } | 127 // Sample new mappings to |page_url|: { ICON_URL1, ICON_URL3 } |
| 130 // 2) If |icon_types| has multiple types, the mappings are only set for the | 128 // 2) If |icon_types| has multiple types, the mappings are only set for the |
| 131 // largest icon type. | 129 // largest icon type. |
| 132 // Sample new mappings to |page_url|: { ICON_URL3 } | 130 // Sample new mappings to |page_url|: { ICON_URL3 } |
| 133 // |icon_types| can only have multiple IconTypes if | 131 // |icon_types| can only have multiple IconTypes if |
| 134 // |icon_types| == TOUCH_ICON | TOUCH_PRECOMPOSED_ICON. | 132 // |icon_types| == TOUCH_ICON | TOUCH_PRECOMPOSED_ICON. |
| 135 // The favicon bitmaps which most closely match |desired_size_in_dip| | 133 // The favicon bitmaps which most closely match |desired_size_in_pixels| |
| 136 // at the reosurce scale factors supported by the current platform (eg MacOS) | 134 // are returned. |
| 137 // in addition to 1x from the favicons which were just mapped to |page_url| | |
| 138 // are returned. If |desired_size_in_dip| is 0, the largest favicon bitmap is | |
| 139 // returned. | |
| 140 virtual base::CancelableTaskTracker::TaskId UpdateFaviconMappingsAndFetch( | 135 virtual base::CancelableTaskTracker::TaskId UpdateFaviconMappingsAndFetch( |
| 141 const GURL& page_url, | 136 const GURL& page_url, |
| 142 const std::vector<GURL>& icon_urls, | 137 const std::vector<GURL>& icon_urls, |
| 143 int icon_types, | 138 int icon_types, |
| 144 int desired_size_in_dip, | 139 const std::vector<int>& desired_sizes_in_pixel, |
| 145 const favicon_base::FaviconResultsCallback& callback, | 140 const favicon_base::FaviconResultsCallback& callback, |
| 146 base::CancelableTaskTracker* tracker) = 0; | 141 base::CancelableTaskTracker* tracker) = 0; |
| 147 | 142 |
| 148 // Used to request a bitmap for the favicon with |favicon_id| which is not | 143 // Used to request a bitmap for the favicon with |favicon_id| which is not |
| 149 // resized from the size it is stored at in the database. If there are | 144 // resized from the size it is stored at in the database. If there are |
| 150 // multiple favicon bitmaps for |favicon_id|, the largest favicon bitmap is | 145 // multiple favicon bitmaps for |favicon_id|, the largest favicon bitmap is |
| 151 // returned. | 146 // returned. |
| 152 virtual base::CancelableTaskTracker::TaskId GetLargestRawFaviconForID( | 147 virtual base::CancelableTaskTracker::TaskId GetLargestRawFaviconForID( |
| 153 favicon_base::FaviconID favicon_id, | 148 favicon_base::FaviconID favicon_id, |
| 154 const favicon_base::FaviconRawBitmapCallback& callback, | 149 const favicon_base::FaviconRawBitmapCallback& callback, |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 | 186 |
| 192 // Avoid repeated requests to download missing favicon. | 187 // Avoid repeated requests to download missing favicon. |
| 193 virtual void UnableToDownloadFavicon(const GURL& icon_url) = 0; | 188 virtual void UnableToDownloadFavicon(const GURL& icon_url) = 0; |
| 194 virtual bool WasUnableToDownloadFavicon(const GURL& icon_url) const = 0; | 189 virtual bool WasUnableToDownloadFavicon(const GURL& icon_url) const = 0; |
| 195 virtual void ClearUnableToDownloadFavicons() = 0; | 190 virtual void ClearUnableToDownloadFavicons() = 0; |
| 196 }; | 191 }; |
| 197 | 192 |
| 198 } // namespace favicon | 193 } // namespace favicon |
| 199 | 194 |
| 200 #endif // COMPONENTS_FAVICON_CORE_FAVICON_SERVICE_H_ | 195 #endif // COMPONENTS_FAVICON_CORE_FAVICON_SERVICE_H_ |
| OLD | NEW |