Vectorize website settings icons in omnibox
[chromium-blink-merge.git] / components / favicon / core / large_icon_service.h
blobeb10c7a24d10c1fba7220bc324161c29aea770b0
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_
8 #include <vector>
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"
14 class GURL;
16 namespace base {
17 class TaskRunner;
20 namespace favicon {
22 class FaviconService;
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);
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(
44 const GURL& page_url,
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();
53 private:
54 // For testing.
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
61 // request.
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_