Add a minor text member to ui::MenuModel.
[chromium-blink-merge.git] / chrome / browser / ui / toolbar / wrench_icon_painter.h
blob5b72e4bf4f5a42f5a76332e3fbb53be41bd1282e
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 "chrome/browser/ui/global_error/global_error.h"
12 #include "chrome/browser/upgrade_detector.h"
13 #include "ui/base/animation/animation_delegate.h"
14 #include "ui/gfx/image/image_skia.h"
16 namespace gfx {
17 class Canvas;
18 class Rect;
20 namespace ui {
21 class MultiAnimation;
22 class ThemeProvider;
25 // This class is used to draw the wrench icon. It can signify severity levels
26 // by changing the wrench icon to different colors.
27 class WrenchIconPainter : ui::AnimationDelegate {
28 public:
29 enum BezelType {
30 BEZEL_NONE,
31 BEZEL_HOVER,
32 BEZEL_PRESSED,
35 enum Severity {
36 SEVERITY_NONE,
37 SEVERITY_LOW,
38 SEVERITY_MEDIUM,
39 SEVERITY_HIGH,
42 class Delegate {
43 public:
44 virtual void ScheduleWrenchIconPaint() = 0;
45 protected:
46 virtual ~Delegate() {}
49 // Map an upgrade level to a severity level.
50 static Severity SeverityFromUpgradeLevel(
51 UpgradeDetector::UpgradeNotificationAnnoyanceLevel level);
53 // Checks if the wrench icon should be animated for the given upgrade level.
54 static bool ShouldAnimateUpgradeLevel(
55 UpgradeDetector::UpgradeNotificationAnnoyanceLevel level);
57 // Get the severity level for global errors.
58 static Severity GlobalErrorSeverity();
60 explicit WrenchIconPainter(Delegate* delegate);
61 virtual ~WrenchIconPainter();
63 // If |severity| is not |SEVERITY_NONE| then the wrench icon is colored to
64 // match the severity level.
65 void SetSeverity(Severity severity, bool animate);
67 // A badge drawn on the top left.
68 void set_badge(const gfx::ImageSkia& badge) { badge_ = badge; }
70 void Paint(gfx::Canvas* canvas,
71 ui::ThemeProvider* theme_provider,
72 const gfx::Rect& rect,
73 BezelType bezel_type);
75 private:
76 FRIEND_TEST_ALL_PREFIXES(WrenchIconPainterTest, PaintCallback);
78 // AnimationDelegate:
79 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE;
81 // Gets the image ID used to draw bars for the current severity level.
82 int GetCurrentSeverityImageID() const;
84 Delegate* delegate_;
85 Severity severity_;
86 gfx::ImageSkia badge_;
87 scoped_ptr<ui::MultiAnimation> animation_;
89 DISALLOW_COPY_AND_ASSIGN(WrenchIconPainter);
92 #endif // CHROME_BROWSER_UI_TOOLBAR_WRENCH_ICON_PAINTER_H_