summaryrefslogtreecommitdiffstats
path: root/chrome/common/extensions/extension.cc
diff options
context:
space:
mode:
authorrsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-08 22:30:24 +0000
committerrsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-08 22:30:24 +0000
commit6ae592e4947c687e6c695b0a3b117dd7512d357e (patch)
treeb17136f89df894ebf10dad5adc531a0e3b172e59 /chrome/common/extensions/extension.cc
parent1e419d42be673bd9b67e4576e8e2b8d5c8c3e0b9 (diff)
downloadchromium_src-6ae592e4947c687e6c695b0a3b117dd7512d357e.zip
chromium_src-6ae592e4947c687e6c695b0a3b117dd7512d357e.tar.gz
chromium_src-6ae592e4947c687e6c695b0a3b117dd7512d357e.tar.bz2
Revert 35802 - Failed Valgrind - Allow an empty list of page actions.
BUG=26050 TEST=Updated existing unit tests ExtensionTest.InitFromValue*, manual testing on Linux. Review URL: http://codereview.chromium.org/523132 TBR=skerner@chromium.org Review URL: http://codereview.chromium.org/535003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35834 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/extensions/extension.cc')
-rw-r--r--chrome/common/extensions/extension.cc31
1 files changed, 14 insertions, 17 deletions
diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc
index 7f9783d..1ccaeec 100644
--- a/chrome/common/extensions/extension.cc
+++ b/chrome/common/extensions/extension.cc
@@ -1079,8 +1079,6 @@ bool Extension::InitFromValue(const DictionaryValue& source, bool require_id,
}
// Initialize page action (optional).
- DictionaryValue* page_action_value = NULL;
-
if (source.HasKey(keys::kPageActions)) {
ListValue* list_value;
if (!source.GetList(keys::kPageActions, &list_value)) {
@@ -1088,29 +1086,28 @@ bool Extension::InitFromValue(const DictionaryValue& source, bool require_id,
return false;
}
- size_t list_value_length = list_value->GetSize();
-
- if (list_value_length == 0u) {
- // A list with zero items is allowed, and is equivalent to not having
- // a page_actions key in the manifest. Don't set |page_action_value|.
- } else if (list_value_length == 1u) {
- if (!list_value->GetDictionary(0, &page_action_value)) {
- *error = errors::kInvalidPageAction;
- return false;
- }
- } else { // list_value_length > 1u.
+ if (list_value->GetSize() != 1u) {
*error = errors::kInvalidPageActionsListSize;
return false;
}
+
+ DictionaryValue* page_action_value;
+ if (!list_value->GetDictionary(0, &page_action_value)) {
+ *error = errors::kInvalidPageAction;
+ return false;
+ }
+
+ page_action_.reset(
+ LoadExtensionActionHelper(page_action_value, error));
+ if (!page_action_.get())
+ return false; // Failed to parse page action definition.
} else if (source.HasKey(keys::kPageAction)) {
+ DictionaryValue* page_action_value;
if (!source.GetDictionary(keys::kPageAction, &page_action_value)) {
*error = errors::kInvalidPageAction;
return false;
}
- }
- // If page_action_value is not NULL, then there was a valid page action.
- if (page_action_value) {
page_action_.reset(
LoadExtensionActionHelper(page_action_value, error));
if (!page_action_.get())
@@ -1120,7 +1117,7 @@ bool Extension::InitFromValue(const DictionaryValue& source, bool require_id,
// Initialize browser action (optional).
if (source.HasKey(keys::kBrowserAction)) {
// Restrict extensions to one UI surface.
- if (page_action_.get()) {
+ if (source.HasKey(keys::kPageAction) || source.HasKey(keys::kPageActions)) {
*error = errors::kOneUISurfaceOnly;
return false;
}