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

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

Issue 996253002: [Fallback Icons] Refactor FallbackIconService to be a BrowserContext-level singleton (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync and merge. Created 5 years, 9 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef COMPONENTS_FAVICON_CORE_FALLBACK_ICON_SERVICE_H_ 5 #ifndef COMPONENTS_FAVICON_CORE_FALLBACK_ICON_SERVICE_H_
6 #define COMPONENTS_FAVICON_CORE_FALLBACK_ICON_SERVICE_H_ 6 #define COMPONENTS_FAVICON_CORE_FALLBACK_ICON_SERVICE_H_
7 7
8 #include <string>
9 #include <vector> 8 #include <vector>
10 9
11 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "components/keyed_service/core/keyed_service.h"
12 12
13 class FallbackIconClient;
13 class GURL; 14 class GURL;
14 15
15 namespace gfx { 16 namespace gfx {
16 class Canvas; 17 class Canvas;
17 } 18 }
18 19
19 namespace favicon_base { 20 namespace favicon_base {
20 struct FallbackIconStyle; 21 struct FallbackIconStyle;
21 } 22 }
22 23
23 // A service to provide methods to render fallback favicons. 24 // A service to provide methods to render fallback favicons.
24 class FallbackIconService { 25 class FallbackIconService : public KeyedService {
25 public: 26 public:
26 explicit FallbackIconService(const std::vector<std::string>& font_list); 27 explicit FallbackIconService(FallbackIconClient* fallback_icon_client);
27 ~FallbackIconService(); 28 ~FallbackIconService() override;
28 29
29 // Renders a fallback icon synchronously and returns the bitmap. Returns an 30 // Renders a fallback icon synchronously and returns the bitmap. Returns an
30 // empty std::vector on failure. |size| is icon width and height in pixels. 31 // empty std::vector on failure. |size| is icon width and height in pixels.
31 std::vector<unsigned char> RenderFallbackIconBitmap( 32 std::vector<unsigned char> RenderFallbackIconBitmap(
32 const GURL& icon_url, 33 const GURL& icon_url,
33 int size, 34 int size,
34 const favicon_base::FallbackIconStyle& style); 35 const favicon_base::FallbackIconStyle& style);
35 36
36 private: 37 private:
37 // Renders a fallback icon on |canvas| at position (|x|, |y|). |size| is icon 38 // Renders a fallback icon on |canvas| at position (|x|, |y|). |size| is icon
38 // width and height in pixels. 39 // width and height in pixels.
39 void DrawFallbackIcon(const GURL& icon_url, 40 void DrawFallbackIcon(const GURL& icon_url,
40 int size, 41 int size,
41 const favicon_base::FallbackIconStyle& style, 42 const favicon_base::FallbackIconStyle& style,
42 gfx::Canvas* canvas); 43 gfx::Canvas* canvas);
43 44
44 std::vector<std::string> font_list_; 45 FallbackIconClient* fallback_icon_client_;
45 46
46 DISALLOW_COPY_AND_ASSIGN(FallbackIconService); 47 DISALLOW_COPY_AND_ASSIGN(FallbackIconService);
47 }; 48 };
48 49
49 #endif // COMPONENTS_FAVICON_CORE_FALLBACK_ICON_SERVICE_H_ 50 #endif // COMPONENTS_FAVICON_CORE_FALLBACK_ICON_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698