OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_COMMON_EXTENSIONS_EXTENSION_ACTION_H_ | 5 #ifndef CHROME_COMMON_EXTENSIONS_EXTENSION_ACTION_H_ |
6 #define CHROME_COMMON_EXTENSIONS_EXTENSION_ACTION_H_ | 6 #define CHROME_COMMON_EXTENSIONS_EXTENSION_ACTION_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 // If the action has a popup, it has a URL and a height. | 75 // If the action has a popup, it has a URL and a height. |
76 GURL popup_url_; | 76 GURL popup_url_; |
77 }; | 77 }; |
78 | 78 |
79 typedef std::map<std::string, ExtensionAction*> ExtensionActionMap; | 79 typedef std::map<std::string, ExtensionAction*> ExtensionActionMap; |
80 | 80 |
81 // This class keeps track of what values each tab uses to override the default | 81 // This class keeps track of what values each tab uses to override the default |
82 // values of the ExtensionAction. | 82 // values of the ExtensionAction. |
83 class ExtensionActionState { | 83 class ExtensionActionState { |
84 public: | 84 public: |
| 85 static void PaintBadge(gfx::Canvas* canvas, const gfx::Rect& bounds, |
| 86 const std::string& text, SkColor text_color, |
| 87 SkColor background_color); |
| 88 |
85 ExtensionActionState(std::string title, int icon_index) | 89 ExtensionActionState(std::string title, int icon_index) |
86 : hidden_(false), title_(title), icon_index_(icon_index), | 90 : hidden_(false), title_(title), icon_index_(icon_index), |
87 badge_background_color_(SkColorSetARGB(255, 218, 0, 24)), | 91 badge_background_color_(SkColorSetARGB(255, 218, 0, 24)), |
88 badge_text_color_(SK_ColorWHITE) { | 92 badge_text_color_(SK_ColorWHITE) { |
89 } | 93 } |
90 | 94 |
91 const std::string& title() const { return title_; } | 95 const std::string& title() const { return title_; } |
92 void set_title(const std::string& title) { title_ = title; } | 96 void set_title(const std::string& title) { title_ = title; } |
93 | 97 |
94 const std::string& badge_text() const { return badge_text_; } | 98 const std::string& badge_text() const { return badge_text_; } |
(...skipping 17 matching lines...) Expand all Loading... |
112 | 116 |
113 int icon_index() const { return icon_index_; } | 117 int icon_index() const { return icon_index_; } |
114 void set_icon_index(int icon_index) { icon_index_ = icon_index; } | 118 void set_icon_index(int icon_index) { icon_index_ = icon_index; } |
115 | 119 |
116 SkBitmap* icon() const { return icon_.get(); } | 120 SkBitmap* icon() const { return icon_.get(); } |
117 void set_icon(SkBitmap* icon) { icon_.reset(icon); } | 121 void set_icon(SkBitmap* icon) { icon_.reset(icon); } |
118 | 122 |
119 bool hidden() const { return hidden_; } | 123 bool hidden() const { return hidden_; } |
120 void set_hidden(bool hidden) { hidden_ = hidden; } | 124 void set_hidden(bool hidden) { hidden_ = hidden; } |
121 | 125 |
122 void PaintBadge(gfx::Canvas* canvas, const gfx::Rect& bounds) const; | |
123 | |
124 private: | 126 private: |
125 // True if the action is in the hidden state. | 127 // True if the action is in the hidden state. |
126 bool hidden_; | 128 bool hidden_; |
127 | 129 |
128 // The title text to use for tooltips and labels. | 130 // The title text to use for tooltips and labels. |
129 std::string title_; | 131 std::string title_; |
130 | 132 |
131 // The icon to use. | 133 // The icon to use. |
132 int icon_index_; | 134 int icon_index_; |
133 | 135 |
134 // If non-NULL, overrides icon_index. | 136 // If non-NULL, overrides icon_index. |
135 scoped_ptr<SkBitmap> icon_; | 137 scoped_ptr<SkBitmap> icon_; |
136 | 138 |
137 // The badge text. | 139 // The badge text. |
138 std::string badge_text_; | 140 std::string badge_text_; |
139 | 141 |
140 // The background color for the badge. | 142 // The background color for the badge. |
141 SkColor badge_background_color_; | 143 SkColor badge_background_color_; |
142 | 144 |
143 // The text color for the badge. | 145 // The text color for the badge. |
144 SkColor badge_text_color_; | 146 SkColor badge_text_color_; |
145 | 147 |
146 DISALLOW_COPY_AND_ASSIGN(ExtensionActionState); | 148 DISALLOW_COPY_AND_ASSIGN(ExtensionActionState); |
147 }; | 149 }; |
148 | 150 |
149 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_ACTION_H_ | 151 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_ACTION_H_ |
OLD | NEW |