Only grant permissions to new extensions from sync if they have the expected version
[chromium-blink-merge.git] / components / favicon / core / large_icon_service.h
blob94aee4bdc328891c110c9307c612f93368598aa1
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 LargeIconService(
29 FaviconService* favicon_service,
30 const scoped_refptr<base::TaskRunner>& background_task_runner);
31 ~LargeIconService() override;
33 // Requests the best large icon for the page at |page_url|.
34 // Case 1. An icon exists whose size is >= |min_source_size_in_pixel|:
35 // - If |desired_size_in_pixel| == 0: returns icon as is.
36 // - Else: returns the icon resized to |desired_size_in_pixel|.
37 // Case 2. An icon exists whose size is < |min_source_size_in_pixel|:
38 // - Extracts dominant color of smaller image, returns a fallback icon style
39 // that has a matching background.
40 // Case 3. No icon exists.
41 // - Returns the default fallback icon style.
42 // For cases 2 and 3, this function returns the style of the fallback icon
43 // instead of rendering an icon so clients can render the icon themselves.
44 base::CancelableTaskTracker::TaskId GetLargeIconOrFallbackStyle(
45 const GURL& page_url,
46 int min_source_size_in_pixel,
47 int desired_size_in_pixel,
48 const favicon_base::LargeIconCallback& callback,
49 base::CancelableTaskTracker* tracker);
51 private:
52 // For testing.
53 friend class TestLargeIconService;
55 FaviconService* favicon_service_;
56 scoped_refptr<base::TaskRunner> background_task_runner_;
58 // A pre-populated list of icon types to consider when looking for large
59 // icons. This is an optimization over populating an icon type vector on each
60 // request.
61 std::vector<int> large_icon_types_;
63 DISALLOW_COPY_AND_ASSIGN(LargeIconService);
66 } // namespace favicon
68 #endif // COMPONENTS_FAVICON_CORE_LARGE_ICON_SERVICE_H_