1 // Copyright 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.
5 #ifndef COMPONENTS_FAVICON_CORE_LARGE_ICON_SERVICE_H_
6 #define COMPONENTS_FAVICON_CORE_LARGE_ICON_SERVICE_H_
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"
24 // The large icon service provides methods to access large icons. It relies on
25 // the favicon service.
26 class LargeIconService
: public KeyedService
{
28 explicit LargeIconService(FaviconService
* favicon_service
);
30 ~LargeIconService() override
;
32 // Requests the best large icon for the page at |page_url|.
33 // Case 1. An icon exists whose size is >= |min_source_size_in_pixel|:
34 // - If |desired_size_in_pixel| == 0: returns icon as is.
35 // - Else: returns the icon resized to |desired_size_in_pixel|.
36 // Case 2. An icon exists whose size is < |min_source_size_in_pixel|:
37 // - Extracts dominant color of smaller image, returns a fallback icon style
38 // that has a matching background.
39 // Case 3. No icon exists.
40 // - Returns the default fallback icon style.
41 // For cases 2 and 3, this function returns the style of the fallback icon
42 // instead of rendering an icon so clients can render the icon themselves.
43 base::CancelableTaskTracker::TaskId
GetLargeIconOrFallbackStyle(
45 int min_source_size_in_pixel
,
46 int desired_size_in_pixel
,
47 const favicon_base::LargeIconCallback
& callback
,
48 base::CancelableTaskTracker
* tracker
);
50 // Returns TaskRunner used to execute background task.
51 virtual scoped_refptr
<base::TaskRunner
> GetBackgroundTaskRunner();
55 friend class TestLargeIconService
;
57 FaviconService
* favicon_service_
;
59 // A pre-populated list of icon types to consider when looking for large
60 // icons. This is an optimization over populating an icon type vector on each
62 std::vector
<int> large_icon_types_
;
64 DISALLOW_COPY_AND_ASSIGN(LargeIconService
);
67 } // namespace favicon
69 #endif // COMPONENTS_FAVICON_CORE_LARGE_ICON_SERVICE_H_