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
3 // found in the LICENSE file.
5 #ifndef CONTENT_RENDERER_V8_VALUE_CONVERTER_IMPL_H_
6 #define CONTENT_RENDERER_V8_VALUE_CONVERTER_IMPL_H_
8 #include "base/compiler_specific.h"
9 #include "content/common/content_export.h"
10 #include "content/public/renderer/v8_value_converter.h"
13 class DictionaryValue
;
18 class CONTENT_EXPORT V8ValueConverterImpl
: public content::V8ValueConverter
{
20 V8ValueConverterImpl();
22 // Use the following setters to support additional types other than the
24 bool allow_undefined() const { return allow_undefined_
; }
25 void set_allow_undefined(bool val
) { allow_undefined_
= val
; }
27 bool allow_date() const { return allow_date_
; }
28 void set_allow_date(bool val
) { allow_date_
= val
; }
30 bool allow_regexp() const { return allow_regexp_
; }
31 void set_allow_regexp(bool val
) { allow_regexp_
= val
; }
33 // V8ValueConverter implementation.
34 virtual v8::Handle
<v8::Value
> ToV8Value(
35 const base::Value
* value
,
36 v8::Handle
<v8::Context
> context
) const OVERRIDE
;
37 virtual base::Value
* FromV8Value(
38 v8::Handle
<v8::Value
> value
,
39 v8::Handle
<v8::Context
> context
) const OVERRIDE
;
42 v8::Handle
<v8::Value
> ToV8ValueImpl(const base::Value
* value
) const;
43 v8::Handle
<v8::Value
> ToV8Array(const base::ListValue
* list
) const;
44 v8::Handle
<v8::Value
> ToV8Object(
45 const base::DictionaryValue
* dictionary
) const;
47 base::Value
* FromV8ValueImpl(v8::Handle
<v8::Value
> value
) const;
48 base::ListValue
* FromV8Array(v8::Handle
<v8::Array
> array
) const;
49 base::DictionaryValue
* FromV8Object(v8::Handle
<v8::Object
> object
) const;
51 // If true, we will convert undefined JavaScript values to null.
52 bool allow_undefined_
;
54 // If true, we will convert Date JavaScript objects to doubles.
57 // If true, we will convet RegExp JavaScript objects to string.
61 #endif // CONTENT_RENDERER_V8_VALUE_CONVERTER_IMPL_H_