Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / components / favicon / core / fallback_icon_service.h
blob56b155e627025968cbaf0841fc838d33b4b04777
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_FALLBACK_ICON_SERVICE_H_
6 #define COMPONENTS_FAVICON_CORE_FALLBACK_ICON_SERVICE_H_
8 #include <vector>
10 #include "base/macros.h"
11 #include "components/keyed_service/core/keyed_service.h"
13 class GURL;
15 namespace gfx {
16 class Canvas;
19 namespace favicon_base {
20 struct FallbackIconStyle;
23 namespace favicon {
25 class FallbackIconClient;
27 // A service to provide methods to render fallback favicons.
28 class FallbackIconService : public KeyedService {
29 public:
30 explicit FallbackIconService(FallbackIconClient* fallback_icon_client);
31 ~FallbackIconService() override;
33 // Renders a fallback icon synchronously and returns the bitmap. Returns an
34 // empty std::vector on failure. |size| is icon width and height in pixels.
35 std::vector<unsigned char> RenderFallbackIconBitmap(
36 const GURL& icon_url,
37 int size,
38 const favicon_base::FallbackIconStyle& style);
40 private:
41 // Renders a fallback icon on |canvas| at position (|x|, |y|). |size| is icon
42 // width and height in pixels.
43 void DrawFallbackIcon(const GURL& icon_url,
44 int size,
45 const favicon_base::FallbackIconStyle& style,
46 gfx::Canvas* canvas);
48 FallbackIconClient* fallback_icon_client_;
50 DISALLOW_COPY_AND_ASSIGN(FallbackIconService);
53 } // namespace favicon
55 #endif // COMPONENTS_FAVICON_CORE_FALLBACK_ICON_SERVICE_H_