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