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 e671d15e71308588b12928fb52aba1f3cfa00d06..d2cb6043abba1b30c23ea1dd32a2db3e29246de4 100644 |
--- a/chrome/browser/extensions/extension_browser_actions_api.cc |
+++ b/chrome/browser/extensions/extension_browser_actions_api.cc |
@@ -17,30 +17,11 @@ const char kIconIndexOutOfBounds[] = |
"Browser action icon index out of bounds."; |
} |
-bool BrowserActionSetNameFunction::RunImpl() { |
- std::string title; |
- EXTENSION_FUNCTION_VALIDATE(args_->GetAsString(&title)); |
- |
- Extension* extension = dispatcher()->GetExtension(); |
- if (!extension->browser_action()) { |
- error_ = kNoBrowserActionError; |
- return false; |
- } |
- |
- extension->browser_action_state()->set_title(title); |
- |
- NotificationService::current()->Notify( |
- NotificationType::EXTENSION_BROWSER_ACTION_UPDATED, |
- Source<ExtensionAction>(extension->browser_action()), |
- Details<ExtensionActionState>(extension->browser_action_state())); |
- return true; |
-} |
- |
bool BrowserActionSetIconFunction::RunImpl() { |
// setIcon can take a variant argument: either a canvas ImageData, or an |
// icon index. |
EXTENSION_FUNCTION_VALIDATE(args_->IsType(Value::TYPE_BINARY) || |
- args_->IsType(Value::TYPE_INTEGER)); |
+ args_->IsType(Value::TYPE_DICTIONARY)); |
Extension* extension = dispatcher()->GetExtension(); |
if (!extension->browser_action()) { |
@@ -58,8 +39,9 @@ bool BrowserActionSetIconFunction::RunImpl() { |
extension->browser_action_state()->set_icon(bitmap.release()); |
} else { |
int icon_index = -1; |
- EXTENSION_FUNCTION_VALIDATE(args_->GetAsInteger(&icon_index)); |
- |
+ EXTENSION_FUNCTION_VALIDATE( |
+ static_cast<DictionaryValue*>(args_)->GetInteger( |
+ L"iconIndex", &icon_index)); |
if (icon_index < 0 || |
static_cast<size_t>(icon_index) >= |
extension->browser_action()->icon_paths().size()) { |
@@ -77,9 +59,34 @@ bool BrowserActionSetIconFunction::RunImpl() { |
return true; |
} |
+bool BrowserActionSetTitleFunction::RunImpl() { |
+ EXTENSION_FUNCTION_VALIDATE(args_->IsType(Value::TYPE_DICTIONARY)); |
+ DictionaryValue* details = static_cast<DictionaryValue*>(args_); |
+ |
+ std::string title; |
+ EXTENSION_FUNCTION_VALIDATE(details->GetString(L"title", &title)); |
+ |
+ Extension* extension = dispatcher()->GetExtension(); |
+ if (!extension->browser_action()) { |
+ error_ = kNoBrowserActionError; |
+ return false; |
+ } |
+ |
+ extension->browser_action_state()->set_title(title); |
+ |
+ NotificationService::current()->Notify( |
+ NotificationType::EXTENSION_BROWSER_ACTION_UPDATED, |
+ Source<ExtensionAction>(extension->browser_action()), |
+ Details<ExtensionActionState>(extension->browser_action_state())); |
+ return true; |
+} |
+ |
bool BrowserActionSetBadgeTextFunction::RunImpl() { |
+ EXTENSION_FUNCTION_VALIDATE(args_->IsType(Value::TYPE_DICTIONARY)); |
+ DictionaryValue* details = static_cast<DictionaryValue*>(args_); |
+ |
std::string badge_text; |
- EXTENSION_FUNCTION_VALIDATE(args_->GetAsString(&badge_text)); |
+ EXTENSION_FUNCTION_VALIDATE(details->GetString(L"text", &badge_text)); |
Extension* extension = dispatcher()->GetExtension(); |
if (!extension->browser_action()) { |
@@ -97,8 +104,11 @@ bool BrowserActionSetBadgeTextFunction::RunImpl() { |
} |
bool BrowserActionSetBadgeBackgroundColorFunction::RunImpl() { |
- EXTENSION_FUNCTION_VALIDATE(args_->IsType(Value::TYPE_LIST)); |
- ListValue* list = static_cast<ListValue*>(args_); |
+ EXTENSION_FUNCTION_VALIDATE(args_->IsType(Value::TYPE_DICTIONARY)); |
+ DictionaryValue* details = static_cast<DictionaryValue*>(args_); |
+ |
+ ListValue* list = NULL; |
+ EXTENSION_FUNCTION_VALIDATE(details->GetList(L"color", &list)); |
EXTENSION_FUNCTION_VALIDATE(list->GetSize() == 4); |
int color_array[4] = {0}; |