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

Side by Side Diff: chrome/test/automation/value_conversion_traits.cc

Issue 7714004: base: Add AsList() function to Value API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix chromeos Created 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/test/automation/tab_proxy.cc ('k') | chrome/test/base/ui_test_utils.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 if (!value->IsType(Value::TYPE_LIST)) 74 ListValue* list = const_cast<Value*>(value)->AsList();
75 if (!list)
75 return false; 76 return false;
76 *t = static_cast<const ListValue*>(value)->DeepCopy(); 77 *t = list->DeepCopy();
77 return true; 78 return true;
78 } 79 }
79 80
80 bool ValueConversionTraits<ListValue*>::CanConvert(const Value* value) { 81 bool ValueConversionTraits<ListValue*>::CanConvert(const Value* value) {
81 return value->IsType(Value::TYPE_LIST); 82 return const_cast<Value*>(value)->AsList();
82 } 83 }
83 84
84 Value* ValueConversionTraits<DictionaryValue*>::CreateValueFrom( 85 Value* ValueConversionTraits<DictionaryValue*>::CreateValueFrom(
85 const DictionaryValue* t) { 86 const DictionaryValue* t) {
86 return t->DeepCopy(); 87 return t->DeepCopy();
87 } 88 }
88 89
89 bool ValueConversionTraits<DictionaryValue*>::SetFromValue( 90 bool ValueConversionTraits<DictionaryValue*>::SetFromValue(
90 const Value* value, DictionaryValue** t) { 91 const Value* value, DictionaryValue** t) {
91 if (!value->IsType(Value::TYPE_DICTIONARY)) 92 if (!value->IsType(Value::TYPE_DICTIONARY))
92 return false; 93 return false;
93 *t = static_cast<const DictionaryValue*>(value)->DeepCopy(); 94 *t = static_cast<const DictionaryValue*>(value)->DeepCopy();
94 return true; 95 return true;
95 } 96 }
96 97
97 bool ValueConversionTraits<DictionaryValue*>::CanConvert(const Value* value) { 98 bool ValueConversionTraits<DictionaryValue*>::CanConvert(const Value* value) {
98 return value->IsType(Value::TYPE_DICTIONARY); 99 return value->IsType(Value::TYPE_DICTIONARY);
99 } 100 }
OLDNEW
« no previous file with comments | « chrome/test/automation/tab_proxy.cc ('k') | chrome/test/base/ui_test_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698