| Index: chrome/browser/extensions/extension_browser_actions_api.cc
|
| diff --git a/chrome/browser/extensions/extension_browser_actions_api.cc b/chrome/browser/extensions/extension_browser_actions_api.cc
|
| index 6087d14ce416be036f8bb3b256218081671d364d..d80637d918023f798b927fe8358fca8acdd598df 100755
|
| --- a/chrome/browser/extensions/extension_browser_actions_api.cc
|
| +++ b/chrome/browser/extensions/extension_browser_actions_api.cc
|
| @@ -12,6 +12,9 @@ namespace extension_browser_actions_api_constants {
|
|
|
| const char kSetNameFunction[] = "browserAction.setName";
|
| const char kSetIconFunction[] = "browserAction.setIcon";
|
| +const char kSetBadgeTextFunction[] = "browserAction.setBadgeText";
|
| +const char kSetBadgeBackgroundColorFunction[] =
|
| + "browserAction.setBadgeBackgroundColor";
|
|
|
| } // namespace extension_browser_actions_api_constants
|
|
|
| @@ -58,3 +61,50 @@ bool BrowserActionSetIconFunction::RunImpl() {
|
| Details<ExtensionActionState>(extension->browser_action_state()));
|
| return true;
|
| }
|
| +
|
| +bool BrowserActionSetBadgeTextFunction::RunImpl() {
|
| + std::string badge_text;
|
| + EXTENSION_FUNCTION_VALIDATE(args_->GetAsString(&badge_text));
|
| +
|
| + Extension* extension = dispatcher()->GetExtension();
|
| + if (!extension->browser_action()) {
|
| + error_ = kNoBrowserActionError;
|
| + return false;
|
| + }
|
| +
|
| + extension->browser_action_state()->set_badge_text(badge_text);
|
| +
|
| + NotificationService::current()->Notify(
|
| + NotificationType::EXTENSION_BROWSER_ACTION_UPDATED,
|
| + Source<ExtensionAction>(extension->browser_action()),
|
| + Details<ExtensionActionState>(extension->browser_action_state()));
|
| + return true;
|
| +}
|
| +
|
| +bool BrowserActionSetBadgeBackgroundColorFunction::RunImpl() {
|
| + EXTENSION_FUNCTION_VALIDATE(args_->IsType(Value::TYPE_LIST));
|
| + ListValue* list = static_cast<ListValue*>(args_);
|
| + EXTENSION_FUNCTION_VALIDATE(list->GetSize() == 4);
|
| +
|
| + int color_array[4] = {0};
|
| + for (size_t i = 0; i < arraysize(color_array); ++i) {
|
| + EXTENSION_FUNCTION_VALIDATE(list->GetInteger(i, &color_array[i]));
|
| + }
|
| +
|
| + SkColor color = SkColorSetARGB(color_array[0], color_array[1], color_array[2],
|
| + color_array[3]);
|
| +
|
| + Extension* extension = dispatcher()->GetExtension();
|
| + if (!extension->browser_action()) {
|
| + error_ = kNoBrowserActionError;
|
| + return false;
|
| + }
|
| +
|
| + extension->browser_action_state()->set_badge_background_color(color);
|
| +
|
| + NotificationService::current()->Notify(
|
| + NotificationType::EXTENSION_BROWSER_ACTION_UPDATED,
|
| + Source<ExtensionAction>(extension->browser_action()),
|
| + Details<ExtensionActionState>(extension->browser_action_state()));
|
| + return true;
|
| +}
|
|
|