OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef COMPONENTS_FAVICON_CORE_LARGE_ICON_SERVICE_H_ |
| 6 #define COMPONENTS_FAVICON_CORE_LARGE_ICON_SERVICE_H_ |
| 7 |
| 8 #include <vector> |
| 9 |
| 10 #include "base/task/cancelable_task_tracker.h" |
| 11 #include "components/favicon_base/favicon_callback.h" |
| 12 #include "components/keyed_service/core/keyed_service.h" |
| 13 |
| 14 class GURL; |
| 15 |
| 16 namespace favicon_base { |
| 17 struct FaviconRawBitmapResult; |
| 18 } |
| 19 |
| 20 namespace favicon { |
| 21 |
| 22 class FaviconService; |
| 23 |
| 24 // The large icon service provides methods to access large icons. It relies on |
| 25 // the favicon service. |
| 26 class LargeIconService : public KeyedService { |
| 27 public: |
| 28 explicit LargeIconService(FaviconService* favicon_service); |
| 29 |
| 30 ~LargeIconService() override; |
| 31 |
| 32 // Requests the best large icon for the page at |page_url| given the requested |
| 33 // |desired_size_in_pixel|. If no good large icon can be found, returns the |
| 34 // fallback style to use, for which the background is set to the dominant |
| 35 // color of a smaller icon when one is available. This function returns the |
| 36 // style of the fallback icon rather than the rendered version so that clients |
| 37 // can render the icon themselves. |
| 38 base::CancelableTaskTracker::TaskId GetLargeIconOrFallbackStyle( |
| 39 const GURL& page_url, |
| 40 int desired_size_in_pixel, |
| 41 const favicon_base::LargeIconCallback& callback, |
| 42 base::CancelableTaskTracker* tracker); |
| 43 |
| 44 private: |
| 45 // Intermediate callback for GetLargeIconOrFallbackStyle(). Ensures the large |
| 46 // icon is at least the desired size, if not compute the icon fallback style |
| 47 // and use it to invoke |callback|. |
| 48 void RunLargeIconCallback( |
| 49 const favicon_base::LargeIconCallback& callback, |
| 50 int desired_size_in_pixel, |
| 51 const favicon_base::FaviconRawBitmapResult& bitmap_result); |
| 52 |
| 53 FaviconService* favicon_service_; |
| 54 |
| 55 // A pre-populated list of the types of icon files to consider when looking |
| 56 // for large icons. This is an optimization over populating an icon type |
| 57 // vector on each request. |
| 58 std::vector<int> large_icon_types_; |
| 59 |
| 60 DISALLOW_COPY_AND_ASSIGN(LargeIconService); |
| 61 }; |
| 62 |
| 63 } // namespace favicon |
| 64 |
| 65 #endif // COMPONENTS_FAVICON_CORE_LARGE_ICON_SERVICE_H_ |
OLD | NEW |