Index: base/values.cc |
diff --git a/base/values.cc b/base/values.cc |
index 6068556bb3d1a4738b0048c118577a8670aef6be..4a7c8245042a602a6de0c8863640c72e8b7b0ac7 100644 |
--- a/base/values.cc |
+++ b/base/values.cc |
@@ -134,6 +134,10 @@ bool Value::GetAsString(string16* out_value) const { |
return false; |
} |
+bool Value::GetAsStringValue(const StringValue** out_value) const { |
+ return false; |
+} |
+ |
bool Value::GetAsList(ListValue** out_value) { |
return false; |
} |
@@ -266,32 +270,40 @@ bool FundamentalValue::Equals(const Value* other) const { |
StringValue::StringValue(const std::string& in_value) |
: Value(TYPE_STRING), |
- value_(in_value) { |
+ value_(new std::string(in_value)) { |
DCHECK(IsStringUTF8(in_value)); |
} |
StringValue::StringValue(const string16& in_value) |
: Value(TYPE_STRING), |
- value_(UTF16ToUTF8(in_value)) { |
-} |
+ value_(new std::string(UTF16ToUTF8(in_value))) {} |
-StringValue::~StringValue() { |
-} |
+StringValue::StringValue(scoped_ptr<std::string> in_value) |
+ : Value(TYPE_STRING), |
+ value_(in_value.Pass()) {} |
+ |
+StringValue::~StringValue() {} |
bool StringValue::GetAsString(std::string* out_value) const { |
if (out_value) |
- *out_value = value_; |
+ *out_value = *value_; |
return true; |
} |
bool StringValue::GetAsString(string16* out_value) const { |
if (out_value) |
- *out_value = UTF8ToUTF16(value_); |
+ *out_value = UTF8ToUTF16(*value_); |
+ return true; |
+} |
+ |
+bool StringValue::GetAsStringValue(const StringValue** out_value) const { |
+ if (out_value) |
+ *out_value = this; |
return true; |
} |
StringValue* StringValue::DeepCopy() const { |
- return CreateStringValue(value_); |
+ return new StringValue(*value_); |
} |
bool StringValue::Equals(const Value* other) const { |