Flesh out ListValue class.

Review URL: http://codereview.chromium.org/18200

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8315 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/base/values.cc b/base/values.cc
index 75b8e4f..cf98c0b0 100644
--- a/base/values.cc
+++ b/base/values.cc
@@ -245,7 +245,7 @@
   dictionary_.clear();
 }
 
-bool DictionaryValue::HasKey(const std::wstring& key) {
+bool DictionaryValue::HasKey(const std::wstring& key) const {
   ValueMap::const_iterator current_entry = dictionary_.find(key);
   DCHECK((current_entry == dictionary_.end()) || current_entry->second);
   return current_entry != dictionary_.end();
@@ -532,8 +532,51 @@
   return true;
 }
 
-bool ListValue::GetDictionary(size_t index,
-                              DictionaryValue** out_value) const {
+bool ListValue::GetBoolean(size_t index, bool* bool_value) const {
+  Value* value;
+  if (!Get(index, &value))
+    return false;
+
+  return value->GetAsBoolean(bool_value);
+}
+
+bool ListValue::GetInteger(size_t index, int* out_value) const {
+  Value* value;
+  if (!Get(index, &value))
+    return false;
+
+  return value->GetAsInteger(out_value);
+}
+
+bool ListValue::GetReal(size_t index, double* out_value) const {
+  Value* value;
+  if (!Get(index, &value))
+    return false;
+
+  return value->GetAsReal(out_value);
+}
+
+bool ListValue::GetString(size_t index, std::string* out_value) const {
+  Value* value;
+  if (!Get(index, &value))
+    return false;
+
+  return value->GetAsString(out_value);
+}
+
+bool ListValue::GetBinary(size_t index, BinaryValue** out_value) const {
+  Value* value;
+  bool result = Get(index, &value);
+  if (!result || !value->IsType(TYPE_BINARY))
+    return false;
+
+  if (out_value)
+    *out_value = static_cast<BinaryValue*>(value);
+
+  return true;
+}
+
+bool ListValue::GetDictionary(size_t index, DictionaryValue** out_value) const {
   Value* value;
   bool result = Get(index, &value);
   if (!result || !value->IsType(TYPE_DICTIONARY))
@@ -545,6 +588,18 @@
   return true;
 }
 
+bool ListValue::GetList(size_t index, ListValue** out_value) const {
+  Value* value;
+  bool result = Get(index, &value);
+  if (!result || !value->IsType(TYPE_LIST))
+    return false;
+
+  if (out_value)
+    *out_value = static_cast<ListValue*>(value);
+
+  return true;
+}
+
 bool ListValue::Remove(size_t index, Value** out_value) {
   if (index >= list_.size())
     return false;