| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 FaviconRawCallback; | 70 FaviconRawCallback; |
| 71 | 71 |
| 72 // Callback for GetFavicon() and GetFaviconForURL(). | 72 // Callback for GetFavicon() and GetFaviconForURL(). |
| 73 // | 73 // |
| 74 // The first argument is the set of bitmaps for the passed in URL and | 74 // The first argument is the set of bitmaps for the passed in URL and |
| 75 // icon types whose pixel sizes best match the passed in | 75 // icon types whose pixel sizes best match the passed in |
| 76 // |desired_size_in_dip| at the scale factors supported by the current | 76 // |desired_size_in_dip| at the scale factors supported by the current |
| 77 // platform (eg MacOS) in addition to 1x. The vector has at most one result | 77 // platform (eg MacOS) in addition to 1x. The vector has at most one result |
| 78 // for each of the scale factors. There are less entries if a single result | 78 // for each of the scale factors. There are less entries if a single result |
| 79 // is the best bitmap to use for several scale factors. | 79 // is the best bitmap to use for several scale factors. |
| 80 // | 80 typedef base::Callback<void(const std::vector<history::FaviconBitmapResult>&)> |
| 81 // Second argument: | |
| 82 // a) If the callback is called as a result of GetFaviconForURL(): | |
| 83 // The second argument is a map of the icon URLs mapped to |page_url| to | |
| 84 // the sizes at which the favicon is available from the web. | |
| 85 // b) If the callback is called as a result of GetFavicon() or | |
| 86 // UpdateFaviconMappingsAndFetch(): | |
| 87 // The second argument is a map of the subset of |icon_urls| known to the | |
| 88 // history backend to a vector of sizes of the favicon bitmaps at each | |
| 89 // URL. If none of |icon_urls| are known to the history backend, an empty | |
| 90 // map is returned. | |
| 91 // See history_types.h for more information about IconURLSizesMap. | |
| 92 typedef base::Callback< | |
| 93 void(const std::vector<history::FaviconBitmapResult>&, | |
| 94 const history::IconURLSizesMap&)> | |
| 95 FaviconResultsCallback; | 81 FaviconResultsCallback; |
| 96 | 82 |
| 97 // We usually pass parameters with pointer to avoid copy. This function is a | 83 // We usually pass parameters with pointer to avoid copy. This function is a |
| 98 // helper to run FaviconResultsCallback with pointer parameters. | 84 // helper to run FaviconResultsCallback with pointer parameters. |
| 99 static void FaviconResultsCallbackRunner( | 85 static void FaviconResultsCallbackRunner( |
| 100 const FaviconResultsCallback& callback, | 86 const FaviconResultsCallback& callback, |
| 101 const std::vector<history::FaviconBitmapResult>* results, | 87 const std::vector<history::FaviconBitmapResult>* results); |
| 102 const history::IconURLSizesMap* size_map); | |
| 103 | 88 |
| 104 // Requests the favicon at |icon_url| of |icon_type| whose size most closely | 89 // Requests the favicon at |icon_url| of |icon_type| whose size most closely |
| 105 // matches |desired_size_in_dip|. If |desired_size_in_dip| is 0, the largest | 90 // matches |desired_size_in_dip|. If |desired_size_in_dip| is 0, the largest |
| 106 // favicon bitmap at |icon_url| is returned. |consumer| is notified when the | 91 // favicon bitmap at |icon_url| is returned. |consumer| is notified when the |
| 107 // bits have been fetched. |icon_url| is the URL of the icon itself, e.g. | 92 // bits have been fetched. |icon_url| is the URL of the icon itself, e.g. |
| 108 // <http://www.google.com/favicon.ico>. | 93 // <http://www.google.com/favicon.ico>. |
| 109 // Each of the three methods below differs in the format of the callback and | 94 // Each of the three methods below differs in the format of the callback and |
| 110 // the requested scale factors. All of the scale factors supported by the | 95 // the requested scale factors. All of the scale factors supported by the |
| 111 // current platform (eg MacOS) are requested for GetFaviconImage(). | 96 // current platform (eg MacOS) are requested for GetFaviconImage(). |
| 112 CancelableTaskTracker::TaskId GetFaviconImage( | 97 CancelableTaskTracker::TaskId GetFaviconImage( |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 const FaviconResultsCallback& callback, | 234 const FaviconResultsCallback& callback, |
| 250 CancelableTaskTracker* tracker); | 235 CancelableTaskTracker* tracker); |
| 251 | 236 |
| 252 // Intermediate callback for GetFaviconImage() and GetFaviconImageForURL() | 237 // Intermediate callback for GetFaviconImage() and GetFaviconImageForURL() |
| 253 // so that history service can deal solely with FaviconResultsCallback. | 238 // so that history service can deal solely with FaviconResultsCallback. |
| 254 // Builds history::FaviconImageResult from |favicon_bitmap_results| and runs | 239 // Builds history::FaviconImageResult from |favicon_bitmap_results| and runs |
| 255 // |callback|. | 240 // |callback|. |
| 256 void RunFaviconImageCallbackWithBitmapResults( | 241 void RunFaviconImageCallbackWithBitmapResults( |
| 257 const FaviconImageCallback& callback, | 242 const FaviconImageCallback& callback, |
| 258 int desired_size_in_dip, | 243 int desired_size_in_dip, |
| 259 const std::vector<history::FaviconBitmapResult>& favicon_bitmap_results, | 244 const std::vector<history::FaviconBitmapResult>& favicon_bitmap_results); |
| 260 const history::IconURLSizesMap& icon_url_sizes_map); | |
| 261 | 245 |
| 262 // Intermediate callback for GetRawFavicon() and GetRawFaviconForURL() | 246 // Intermediate callback for GetRawFavicon() and GetRawFaviconForURL() |
| 263 // so that history service can deal solely with FaviconResultsCallback. | 247 // so that history service can deal solely with FaviconResultsCallback. |
| 264 // Resizes history::FaviconBitmapResult if necessary and runs |callback|. | 248 // Resizes history::FaviconBitmapResult if necessary and runs |callback|. |
| 265 void RunFaviconRawCallbackWithBitmapResults( | 249 void RunFaviconRawCallbackWithBitmapResults( |
| 266 const FaviconRawCallback& callback, | 250 const FaviconRawCallback& callback, |
| 267 int desired_size_in_dip, | 251 int desired_size_in_dip, |
| 268 ui::ScaleFactor desired_scale_factor, | 252 ui::ScaleFactor desired_scale_factor, |
| 269 const std::vector<history::FaviconBitmapResult>& favicon_bitmap_results, | 253 const std::vector<history::FaviconBitmapResult>& favicon_bitmap_results); |
| 270 const history::IconURLSizesMap& icon_url_sizes_map); | |
| 271 | 254 |
| 272 DISALLOW_COPY_AND_ASSIGN(FaviconService); | 255 DISALLOW_COPY_AND_ASSIGN(FaviconService); |
| 273 }; | 256 }; |
| 274 | 257 |
| 275 #endif // CHROME_BROWSER_FAVICON_FAVICON_SERVICE_H_ | 258 #endif // CHROME_BROWSER_FAVICON_FAVICON_SERVICE_H_ |
| OLD | NEW |