summaryrefslogtreecommitdiffstats
path: root/chrome/common/extensions/extension.cc
diff options
context:
space:
mode:
authorerikkay@chromium.org <erikkay@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-26 00:11:42 +0000
committererikkay@chromium.org <erikkay@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-26 00:11:42 +0000
commitbbc94554729407f821d4a60828c5758a112f042a (patch)
treefa92103aa16e6ff04e90206c6ac99710c3c2d7ca /chrome/common/extensions/extension.cc
parent4289d9b66a1453aad1115f6ede0007faab22d6d4 (diff)
downloadchromium_src-bbc94554729407f821d4a60828c5758a112f042a.zip
chromium_src-bbc94554729407f821d4a60828c5758a112f042a.tar.gz
chromium_src-bbc94554729407f821d4a60828c5758a112f042a.tar.bz2
add mole info to toolstrip definition and enable moles
Review URL: http://codereview.chromium.org/159202 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21621 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/extensions/extension.cc')
-rw-r--r--chrome/common/extensions/extension.cc38
1 files changed, 36 insertions, 2 deletions
diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc
index b5e0684..ac1607a 100644
--- a/chrome/common/extensions/extension.cc
+++ b/chrome/common/extensions/extension.cc
@@ -751,8 +751,42 @@ bool Extension::InitFromValue(const DictionaryValue& source, bool require_id,
}
for (size_t i = 0; i < list_value->GetSize(); ++i) {
- std::string toolstrip;
- if (!list_value->GetString(i, &toolstrip)) {
+ ToolstripInfo toolstrip;
+ DictionaryValue* toolstrip_value;
+ std::string toolstrip_path;
+ if (list_value->GetString(i, &toolstrip_path)) {
+ // Support a simple URL value for backwards compatibility.
+ // TODO(erikkay) Perhaps deprecate this in the future.
+ toolstrip.toolstrip = GetResourceURL(toolstrip_path);
+ } else if (list_value->GetDictionary(i, &toolstrip_value)) {
+ if (!toolstrip_value->GetString(keys::kToolstripPath,
+ &toolstrip_path)) {
+ *error = ExtensionErrorUtils::FormatErrorMessage(
+ errors::kInvalidToolstrip, IntToString(i));
+ return false;
+ }
+ toolstrip.toolstrip = GetResourceURL(toolstrip_path);
+ if (toolstrip_value->HasKey(keys::kToolstripMolePath)) {
+ std::string mole_path;
+ if (!toolstrip_value->GetString(keys::kToolstripMolePath,
+ &mole_path)) {
+ *error = ExtensionErrorUtils::FormatErrorMessage(
+ errors::kInvalidToolstrip, IntToString(i));
+ return false;
+ }
+ // TODO(erikkay) is there a better way to get this dynamically
+ // from the content itself?
+ int height;
+ if (!toolstrip_value->GetInteger(keys::kToolstripMoleHeight,
+ &height) || (height < 0)) {
+ *error = ExtensionErrorUtils::FormatErrorMessage(
+ errors::kInvalidToolstrip, IntToString(i));
+ return false;
+ }
+ toolstrip.mole = GetResourceURL(mole_path);
+ toolstrip.mole_height = height;
+ }
+ } else {
*error = ExtensionErrorUtils::FormatErrorMessage(
errors::kInvalidToolstrip, IntToString(i));
return false;