| 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 ExtensionActionState(std::string title, int icon_index) | 85 ExtensionActionState(std::string title, int icon_index) |
| 86 : hidden_(false), title_(title), icon_index_(icon_index), | 86 : hidden_(false), title_(title), icon_index_(icon_index), |
| 87 badge_background_color_(SkColorSetARGB(255, 218, 0, 24)) { | 87 badge_background_color_(SkColorSetARGB(255, 218, 0, 24)), |
| 88 badge_text_color_(SK_ColorWHITE) { |
| 88 } | 89 } |
| 89 | 90 |
| 90 const std::string& title() const { return title_; } | 91 const std::string& title() const { return title_; } |
| 91 void set_title(const std::string& title) { title_ = title; } | 92 void set_title(const std::string& title) { title_ = title; } |
| 92 | 93 |
| 93 const std::string& badge_text() const { return badge_text_; } | 94 const std::string& badge_text() const { return badge_text_; } |
| 94 void set_badge_text(const std::string& badge_text) { | 95 void set_badge_text(const std::string& badge_text) { |
| 95 badge_text_ = badge_text; | 96 badge_text_ = badge_text; |
| 96 } | 97 } |
| 97 | 98 |
| 98 SkColor badge_background_color() const { | 99 SkColor badge_background_color() const { |
| 99 return badge_background_color_; | 100 return badge_background_color_; |
| 100 } | 101 } |
| 101 void set_badge_background_color(SkColor badge_background_color) { | 102 void set_badge_background_color(SkColor badge_background_color) { |
| 102 badge_background_color_ = badge_background_color; | 103 badge_background_color_ = badge_background_color; |
| 103 } | 104 } |
| 104 | 105 |
| 106 SkColor badge_text_color() const { |
| 107 return badge_text_color_; |
| 108 } |
| 109 void set_badge_text_color(SkColor badge_text_color) { |
| 110 badge_text_color_ = badge_text_color; |
| 111 } |
| 112 |
| 105 int icon_index() const { return icon_index_; } | 113 int icon_index() const { return icon_index_; } |
| 106 void set_icon_index(int icon_index) { icon_index_ = icon_index; } | 114 void set_icon_index(int icon_index) { icon_index_ = icon_index; } |
| 107 | 115 |
| 108 SkBitmap* icon() const { return icon_.get(); } | 116 SkBitmap* icon() const { return icon_.get(); } |
| 109 void set_icon(SkBitmap* icon) { icon_.reset(icon); } | 117 void set_icon(SkBitmap* icon) { icon_.reset(icon); } |
| 110 | 118 |
| 111 bool hidden() const { return hidden_; } | 119 bool hidden() const { return hidden_; } |
| 112 void set_hidden(bool hidden) { hidden_ = hidden; } | 120 void set_hidden(bool hidden) { hidden_ = hidden; } |
| 113 | 121 |
| 114 void PaintBadge(gfx::Canvas* canvas, const gfx::Rect& bounds); | 122 void PaintBadge(gfx::Canvas* canvas, const gfx::Rect& bounds) const; |
| 115 | 123 |
| 116 private: | 124 private: |
| 117 // True if the action is in the hidden state. | 125 // True if the action is in the hidden state. |
| 118 bool hidden_; | 126 bool hidden_; |
| 119 | 127 |
| 120 // The title text to use for tooltips and labels. | 128 // The title text to use for tooltips and labels. |
| 121 std::string title_; | 129 std::string title_; |
| 122 | 130 |
| 123 // The icon to use. | 131 // The icon to use. |
| 124 int icon_index_; | 132 int icon_index_; |
| 125 | 133 |
| 126 // If non-NULL, overrides icon_index. | 134 // If non-NULL, overrides icon_index. |
| 127 scoped_ptr<SkBitmap> icon_; | 135 scoped_ptr<SkBitmap> icon_; |
| 128 | 136 |
| 129 // The badge text. | 137 // The badge text. |
| 130 std::string badge_text_; | 138 std::string badge_text_; |
| 131 | 139 |
| 132 // The background color for the badge. | 140 // The background color for the badge. |
| 133 SkColor badge_background_color_; | 141 SkColor badge_background_color_; |
| 134 | 142 |
| 143 // The text color for the badge. |
| 144 SkColor badge_text_color_; |
| 145 |
| 135 DISALLOW_COPY_AND_ASSIGN(ExtensionActionState); | 146 DISALLOW_COPY_AND_ASSIGN(ExtensionActionState); |
| 136 }; | 147 }; |
| 137 | 148 |
| 138 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_ACTION_H_ | 149 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_ACTION_H_ |
| OLD | NEW |