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 EXTENSIONS_BROWSER_EXTENSION_ICON_PLACEHOLDER_H_
6 #define EXTENSIONS_BROWSER_EXTENSION_ICON_PLACEHOLDER_H_
10 #include "base/macros.h"
11 #include "base/strings/string16.h"
12 #include "extensions/common/constants.h"
13 #include "ui/gfx/image/canvas_image_source.h"
14 #include "ui/gfx/image/image.h"
21 namespace extensions
{
23 // An extension icon image with a gray background and the first letter of the
24 // extension name, so that not all extensions without an icon look the same.
25 class ExtensionIconPlaceholder
: public gfx::CanvasImageSource
{
27 ExtensionIconPlaceholder(extension_misc::ExtensionIcons size
,
28 const std::string
& name
);
29 ~ExtensionIconPlaceholder() override
;
31 // Creates an image backed by an ImageSkia with the ExtensionIconPlaceholder
32 // as its image source.
33 static gfx::Image
CreateImage(extension_misc::ExtensionIcons size
,
34 const std::string
& name
);
37 // gfx::CanvasImageSource:
38 void Draw(gfx::Canvas
* canvas
) override
;
40 // The size this placeholder is filling.
41 extension_misc::ExtensionIcons icon_size_
;
43 // The first letter of the extension's name.
44 base::string16 letter_
;
46 // The gray background image, on top of which the letter is drawn.
47 gfx::Image base_image_
;
49 DISALLOW_COPY_AND_ASSIGN(ExtensionIconPlaceholder
);
52 } // namespace extensions
54 #endif // EXTENSIONS_BROWSER_EXTENSION_ICON_PLACEHOLDER_H_