OLD | NEW |
| (Empty) |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/common/serialized_script_value.h" | |
6 | |
7 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSerializedScriptVa
lue.h" | |
8 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" | |
9 | |
10 using WebKit::WebSerializedScriptValue; | |
11 | |
12 SerializedScriptValue::SerializedScriptValue() | |
13 : is_null_(true), | |
14 is_invalid_(false) { | |
15 } | |
16 | |
17 SerializedScriptValue::SerializedScriptValue( | |
18 bool is_null, bool is_invalid, const string16& data) | |
19 : is_null_(is_null), | |
20 is_invalid_(is_invalid), | |
21 data_(data) { | |
22 } | |
23 | |
24 SerializedScriptValue::SerializedScriptValue( | |
25 const WebSerializedScriptValue& value) { | |
26 set_web_serialized_script_value(value); | |
27 } | |
28 | |
29 SerializedScriptValue::operator WebSerializedScriptValue() const { | |
30 if (is_null_) | |
31 return WebSerializedScriptValue(); | |
32 if (is_invalid_) | |
33 return WebSerializedScriptValue::createInvalid(); | |
34 return WebSerializedScriptValue::fromString(data_); | |
35 } | |
36 | |
37 void SerializedScriptValue::set_web_serialized_script_value( | |
38 const WebSerializedScriptValue& value) { | |
39 is_null_ = value.isNull(); | |
40 is_invalid_ = value.isNull() ? false : value.toString().isNull(); | |
41 data_ = value.isNull() ? string16() : static_cast<string16>(value.toString()); | |
42 } | |
OLD | NEW |