Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / ui / toolbar / wrench_icon_painter.h
blobc50d7b20d2d5ded350fa2124e97ac94bd1fa2e3d
1 // Copyright (c) 2013 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 CHROME_BROWSER_UI_TOOLBAR_WRENCH_ICON_PAINTER_H_
6 #define CHROME_BROWSER_UI_TOOLBAR_WRENCH_ICON_PAINTER_H_
8 #include "base/compiler_specific.h"
9 #include "base/gtest_prod_util.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "ui/gfx/animation/animation_delegate.h"
12 #include "ui/gfx/image/image_skia.h"
14 namespace gfx {
15 class Canvas;
16 class MultiAnimation;
17 class Rect;
19 namespace ui {
20 class ThemeProvider;
23 // This class is used to draw the wrench icon. It can signify severity levels
24 // by changing the wrench icon to different colors.
25 class WrenchIconPainter : gfx::AnimationDelegate {
26 public:
27 enum BezelType {
28 BEZEL_NONE,
29 BEZEL_HOVER,
30 BEZEL_PRESSED,
33 enum Severity {
34 SEVERITY_NONE,
35 SEVERITY_LOW,
36 SEVERITY_MEDIUM,
37 SEVERITY_HIGH,
40 class Delegate {
41 public:
42 virtual void ScheduleWrenchIconPaint() = 0;
43 protected:
44 virtual ~Delegate() {}
47 explicit WrenchIconPainter(Delegate* delegate);
48 ~WrenchIconPainter() override;
50 // If |severity| is not |SEVERITY_NONE| then the wrench icon is colored to
51 // match the severity level.
52 void SetSeverity(Severity severity, bool animate);
54 // A badge drawn on the top left.
55 void set_badge(const gfx::ImageSkia& badge) { badge_ = badge; }
57 void Paint(gfx::Canvas* canvas,
58 ui::ThemeProvider* theme_provider,
59 const gfx::Rect& rect,
60 BezelType bezel_type);
62 private:
63 FRIEND_TEST_ALL_PREFIXES(WrenchIconPainterTest, PaintCallback);
65 // AnimationDelegate:
66 void AnimationProgressed(const gfx::Animation* animation) override;
68 // Gets the image ID used to draw bars for the current severity level.
69 int GetCurrentSeverityImageID() const;
71 Delegate* delegate_;
72 Severity severity_;
73 gfx::ImageSkia badge_;
74 scoped_ptr<gfx::MultiAnimation> animation_;
76 DISALLOW_COPY_AND_ASSIGN(WrenchIconPainter);
79 #endif // CHROME_BROWSER_UI_TOOLBAR_WRENCH_ICON_PAINTER_H_