summaryrefslogtreecommitdiffstats
path: root/chrome/common
diff options
context:
space:
mode:
authoraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-03 19:39:24 +0000
committeraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-03 19:39:24 +0000
commit5132483c2e2775f0e6bcc249e1438cf88dac97a2 (patch)
treeefa309ebfc998bec325fcfafa0663ec53982ae58 /chrome/common
parente8bce8f868f0ffbd8d608461eb938ee4cc4c0020 (diff)
downloadchromium_src-5132483c2e2775f0e6bcc249e1438cf88dac97a2.zip
chromium_src-5132483c2e2775f0e6bcc249e1438cf88dac97a2.tar.gz
chromium_src-5132483c2e2775f0e6bcc249e1438cf88dac97a2.tar.bz2
Add an API to manipulate the browser action badge.
BUG=23268 Review URL: http://codereview.chromium.org/256032 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27951 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common')
-rwxr-xr-xchrome/common/extensions/api/extension_api.json31
-rw-r--r--chrome/common/extensions/extension_action.h25
2 files changed, 52 insertions, 4 deletions
diff --git a/chrome/common/extensions/api/extension_api.json b/chrome/common/extensions/api/extension_api.json
index 357944c..1a8035b 100755
--- a/chrome/common/extensions/api/extension_api.json
+++ b/chrome/common/extensions/api/extension_api.json
@@ -809,7 +809,7 @@
{
"name": "setName",
"type": "function",
- "description": "Sets the extension's browser action name.",
+ "description": "Sets the text for the browser action. Shows up in the tooltip if the browser action is visible, and in the menu item.",
"parameters": [
{"type": "string", "name": "name", "description": "The string the browser action should display when moused over.", optional: false}
]
@@ -817,10 +817,37 @@
{
"name": "setIcon",
"type": "function",
- "description": "Sets icon",
+ "description": "Sets the icon for the browser action. Can be up to about 22px square.",
"parameters": [
{"type": "integer", "name": "iconId", "minimum": 0, "optional": true, "description": "A zero-based index into the |icons| vector specified in the manifest. This id is useful to represent different browser action states. Example: A GMail checker could have a 'new email' icon and a 'no unread email' icon."}
]
+ },
+ {
+ "name": "setBadgeText",
+ "type": "function",
+ "description": "Sets the badge text for the browser action. This is printed on top of the icon.",
+ "parameters": [
+ {"type": "string", "name": "text", "description": "Any number of characters can be passed, but only about four can fit in the space."}
+ ]
+ },
+ {
+ "name": "setBadgeBackgroundColor",
+ "type": "function",
+ "description": "Sets the background color for the badge.",
+ "parameters": [
+ {
+ "type": "array",
+ "name": "color",
+ "description": "An array of four integers in the range [0,255] that make up the ARGB color for the bakground of the badge.",
+ "items": {
+ "type": "integer",
+ "minimum": 0,
+ "maximum": 255
+ },
+ "minItems": 4,
+ "maxItems": 4
+ }
+ ]
}
],
"events": [
diff --git a/chrome/common/extensions/extension_action.h b/chrome/common/extensions/extension_action.h
index 630671c..70ea093 100644
--- a/chrome/common/extensions/extension_action.h
+++ b/chrome/common/extensions/extension_action.h
@@ -10,7 +10,9 @@
#include <vector>
#include "base/basictypes.h"
+#include "base/scoped_ptr.h"
#include "googleurl/src/gurl.h"
+#include "third_party/skia/include/core/SkColor.h"
class ExtensionAction {
public:
@@ -85,12 +87,25 @@ typedef std::map<std::string, ExtensionAction*> ExtensionActionMap;
class ExtensionActionState {
public:
ExtensionActionState(std::string title, int icon_index)
- : title_(title), icon_index_(icon_index) {
+ : title_(title), icon_index_(icon_index),
+ badge_background_color_(new SkColor(SkColorSetARGB(255, 218, 0, 24))) {
}
- std::string title() const { return title_; }
+ const std::string& title() const { return title_; }
void set_title(const std::string& title) { title_ = title; }
+ const std::string& badge_text() const { return badge_text_; }
+ void set_badge_text(const std::string& badge_text) {
+ badge_text_ = badge_text;
+ }
+
+ SkColor* badge_background_color() const {
+ return badge_background_color_.get();
+ }
+ void set_badge_background_color(const SkColor& badge_background_color) {
+ badge_background_color_.reset(new SkColor(badge_background_color));
+ }
+
int icon_index() const { return icon_index_; }
void set_icon_index(int icon_index) { icon_index_ = icon_index; }
@@ -101,6 +116,12 @@ class ExtensionActionState {
// The icon to use.
int icon_index_;
+ // The badge text.
+ std::string badge_text_;
+
+ // The background color for the badge.
+ scoped_ptr<SkColor> badge_background_color_;
+
DISALLOW_COPY_AND_ASSIGN(ExtensionActionState);
};