Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(263)

Side by Side Diff: components/favicon/core/large_icon_service.h

Issue 1092873002: [Icons NTP] Refactor large_icon_source to extract the logic shared between desktop and Android to f… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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.
36 base::CancelableTaskTracker::TaskId GetLargeIconOrFallbackStyle(
37 const GURL& page_url,
38 int desired_size_in_pixel,
39 const favicon_base::LargeIconCallback& callback,
40 base::CancelableTaskTracker* tracker);
41
42 private:
43 // Intermediate callback for GetLargeIconOrFallbackStyle(). Ensures the large
44 // icon is at least the desired size, if not compute the icon fallback style
45 // and use it to invoke |callback|.
46 void RunLargeIconCallback(
47 const favicon_base::LargeIconCallback& callback,
48 int desired_size_in_pixel,
49 const favicon_base::FaviconRawBitmapResult& bitmap_result);
50
51 FaviconService* favicon_service_;
52
53 // A pre-populated list of the types of icon files to consider when looking
54 // for large icons. Note: this is simply an optimization over populating an
pkotwicz 2015/04/21 18:19:48 Nit: "Note: this is simply an optimization" -> "Th
beaudoin 2015/04/21 19:03:23 Done.
55 // icon type vector on each request.
56 std::vector<int> large_icon_types_;
57
58 DISALLOW_COPY_AND_ASSIGN(LargeIconService);
59 };
60
61 } // namespace favicon
62
63 #endif // COMPONENTS_FAVICON_CORE_LARGE_ICON_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698