| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/test/automation/value_conversion_traits.h" | 5 #include "chrome/test/automation/value_conversion_traits.h" |
| 6 | 6 |
| 7 #include "base/values.h" | 7 #include "base/values.h" |
| 8 | 8 |
| 9 using base::DictionaryValue; | 9 using base::DictionaryValue; |
| 10 using base::ListValue; | 10 using base::ListValue; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 bool ValueConversionTraits<Value*>::CanConvert(const Value* value) { | 64 bool ValueConversionTraits<Value*>::CanConvert(const Value* value) { |
| 65 return true; | 65 return true; |
| 66 } | 66 } |
| 67 | 67 |
| 68 Value* ValueConversionTraits<ListValue*>::CreateValueFrom(const ListValue* t) { | 68 Value* ValueConversionTraits<ListValue*>::CreateValueFrom(const ListValue* t) { |
| 69 return t->DeepCopy(); | 69 return t->DeepCopy(); |
| 70 } | 70 } |
| 71 | 71 |
| 72 bool ValueConversionTraits<ListValue*>::SetFromValue(const Value* value, | 72 bool ValueConversionTraits<ListValue*>::SetFromValue(const Value* value, |
| 73 ListValue** t) { | 73 ListValue** t) { |
| 74 ListValue* list = const_cast<Value*>(value)->AsList(); | 74 if (!value->IsType(Value::TYPE_LIST)) |
| 75 if (!list) | |
| 76 return false; | 75 return false; |
| 77 *t = list->DeepCopy(); | 76 *t = static_cast<const ListValue*>(value)->DeepCopy(); |
| 78 return true; | 77 return true; |
| 79 } | 78 } |
| 80 | 79 |
| 81 bool ValueConversionTraits<ListValue*>::CanConvert(const Value* value) { | 80 bool ValueConversionTraits<ListValue*>::CanConvert(const Value* value) { |
| 82 return const_cast<Value*>(value)->AsList(); | 81 return value->IsType(Value::TYPE_LIST); |
| 83 } | 82 } |
| 84 | 83 |
| 85 Value* ValueConversionTraits<DictionaryValue*>::CreateValueFrom( | 84 Value* ValueConversionTraits<DictionaryValue*>::CreateValueFrom( |
| 86 const DictionaryValue* t) { | 85 const DictionaryValue* t) { |
| 87 return t->DeepCopy(); | 86 return t->DeepCopy(); |
| 88 } | 87 } |
| 89 | 88 |
| 90 bool ValueConversionTraits<DictionaryValue*>::SetFromValue( | 89 bool ValueConversionTraits<DictionaryValue*>::SetFromValue( |
| 91 const Value* value, DictionaryValue** t) { | 90 const Value* value, DictionaryValue** t) { |
| 92 if (!value->IsType(Value::TYPE_DICTIONARY)) | 91 if (!value->IsType(Value::TYPE_DICTIONARY)) |
| 93 return false; | 92 return false; |
| 94 *t = static_cast<const DictionaryValue*>(value)->DeepCopy(); | 93 *t = static_cast<const DictionaryValue*>(value)->DeepCopy(); |
| 95 return true; | 94 return true; |
| 96 } | 95 } |
| 97 | 96 |
| 98 bool ValueConversionTraits<DictionaryValue*>::CanConvert(const Value* value) { | 97 bool ValueConversionTraits<DictionaryValue*>::CanConvert(const Value* value) { |
| 99 return value->IsType(Value::TYPE_DICTIONARY); | 98 return value->IsType(Value::TYPE_DICTIONARY); |
| 100 } | 99 } |
| OLD | NEW |