Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5816)

Unified Diff: chrome/common/extensions/extension.cc

Issue 246037: Integrate browser actions with the wrench menu. Browser actions (Closed)
Patch Set: alphabetize Created 11 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/chrome.gyp ('k') | chrome/common/page_action.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/extensions/extension.cc
diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc
index d68e91f2fb64c6015050cbb7631b48bf73722be5..dd194eb17e6ad877c9f8e6bedf7e1f61094db324 100644
--- a/chrome/common/extensions/extension.cc
+++ b/chrome/common/extensions/extension.cc
@@ -320,29 +320,34 @@ ContextualAction* Extension::LoadContextualActionHelper(
result->set_extension_id(id());
result->set_type(action_type);
- ListValue* icons;
+ ListValue* icons = NULL;
// Read the page action |icons|.
if (!page_action->HasKey(keys::kPageActionIcons) ||
!page_action->GetList(keys::kPageActionIcons, &icons) ||
icons->GetSize() == 0) {
- *error = ExtensionErrorUtils::FormatErrorMessage(
- errors::kInvalidPageActionIconPaths, IntToString(definition_index));
- return NULL;
- }
-
- int icon_count = 0;
- for (ListValue::const_iterator iter = icons->begin();
- iter != icons->end(); ++iter) {
- std::string path;
- if (!(*iter)->GetAsString(&path) || path.empty()) {
+ // Icons are only required for page actions.
+ if (action_type == ContextualAction::PAGE_ACTION) {
*error = ExtensionErrorUtils::FormatErrorMessage(
- errors::kInvalidPageActionIconPath,
- IntToString(definition_index), IntToString(icon_count));
+ errors::kInvalidPageActionIconPaths, IntToString(definition_index));
return NULL;
}
+ }
- result->AddIconPath(path);
- ++icon_count;
+ int icon_count = 0;
+ if (icons) {
+ for (ListValue::const_iterator iter = icons->begin();
+ iter != icons->end(); ++iter) {
+ std::string path;
+ if (!(*iter)->GetAsString(&path) || path.empty()) {
+ *error = ExtensionErrorUtils::FormatErrorMessage(
+ errors::kInvalidPageActionIconPath,
+ IntToString(definition_index), IntToString(icon_count));
+ return NULL;
+ }
+
+ result->AddIconPath(path);
+ ++icon_count;
+ }
}
if (action_type == ContextualAction::BROWSER_ACTION) {
« no previous file with comments | « chrome/chrome.gyp ('k') | chrome/common/page_action.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698