Revert "Fix broken channel icon in chrome://help on CrOS" and try again
[chromium-blink-merge.git] / extensions / browser / extension_icon_placeholder.h
blob5c5e90238f97854033a45121160078972cfe7805
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_
8 #include <string>
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"
16 namespace gfx {
17 class Canvas;
18 class Size;
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 {
26 public:
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);
36 private:
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_