blob: a3e964406ee45f6b4c4e9b94dfdf561edf81e897 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_PUBLIC_RENDERER_V8_VALUE_CONVERTER_H_
#define CONTENT_PUBLIC_RENDERER_V8_VALUE_CONVERTER_H_
#include "content/common/content_export.h"
#include "v8/include/v8.h"
namespace base {
class DictionaryValue;
class ListValue;
class Value;
}
namespace content {
// Converts between v8::Value (JavaScript values in the v8 heap) and Chrome's
// values (from base/values.h). Lists and dictionaries are converted
// recursively.
//
// Only the JSON types (null, boolean, string, number, array, and object) are
// supported.
class CONTENT_EXPORT V8ValueConverter {
public:
static V8ValueConverter* create();
virtual ~V8ValueConverter() {}
// Converts Value to v8::Value. Unsupported types are replaced with null.
// If an array or object throws while setting a value, that property or item
// is skipped, leaving a hole in the case of arrays.
virtual v8::Handle<v8::Value> ToV8Value(
base::Value* value,
v8::Handle<v8::Context> context) const = 0;
// Converts v8::Value to Value. Unsupported types are replaced with null.
// If an array or object throws while getting a value, that property or item
// is replaced with null.
virtual base::Value* FromV8Value(v8::Handle<v8::Value> value,
v8::Handle<v8::Context> context) const = 0;
};
} // namespace content
#endif // CONTENT_PUBLIC_RENDERER_V8_VALUE_CONVERTER_H_
|