1 // Copyright (c) 2012 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_
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "content/common/content_export.h"
13 #include "content/public/renderer/v8_value_converter.h"
17 class DictionaryValue
;
24 class CONTENT_EXPORT V8ValueConverterImpl
: public V8ValueConverter
{
26 V8ValueConverterImpl();
28 // V8ValueConverter implementation.
29 virtual void SetDateAllowed(bool val
) OVERRIDE
;
30 virtual void SetRegExpAllowed(bool val
) OVERRIDE
;
31 virtual void SetFunctionAllowed(bool val
) OVERRIDE
;
32 virtual void SetStripNullFromObjects(bool val
) OVERRIDE
;
33 virtual v8::Handle
<v8::Value
> ToV8Value(
34 const base::Value
* value
,
35 v8::Handle
<v8::Context
> context
) const OVERRIDE
;
36 virtual base::Value
* FromV8Value(
37 v8::Handle
<v8::Value
> value
,
38 v8::Handle
<v8::Context
> context
) const OVERRIDE
;
41 friend class ScopedAvoidIdentityHashForTesting
;
43 class FromV8ValueState
;
45 v8::Handle
<v8::Value
> ToV8ValueImpl(const base::Value
* value
) const;
46 v8::Handle
<v8::Value
> ToV8Array(const base::ListValue
* list
) const;
47 v8::Handle
<v8::Value
> ToV8Object(
48 const base::DictionaryValue
* dictionary
) const;
49 v8::Handle
<v8::Value
> ToArrayBuffer(const base::BinaryValue
* value
) const;
51 base::Value
* FromV8ValueImpl(v8::Handle
<v8::Value
> value
,
52 FromV8ValueState
* state
) const;
53 base::Value
* FromV8Array(v8::Handle
<v8::Array
> array
,
54 FromV8ValueState
* state
) const;
56 // This will convert objects of type ArrayBuffer or any of the
57 // ArrayBufferView subclasses. The return value will be NULL if |value| is
58 // not one of these types.
59 base::BinaryValue
* FromV8Buffer(v8::Handle
<v8::Value
> value
) const;
61 base::Value
* FromV8Object(v8::Handle
<v8::Object
> object
,
62 FromV8ValueState
* state
) const;
64 // If true, we will convert Date JavaScript objects to doubles.
67 // If true, we will convert RegExp JavaScript objects to string.
68 bool reg_exp_allowed_
;
70 // If true, we will convert Function JavaScript objects to dictionaries.
71 bool function_allowed_
;
73 // If true, undefined and null values are ignored when converting v8 objects
75 bool strip_null_from_objects_
;
77 bool avoid_identity_hash_for_testing_
;
79 DISALLOW_COPY_AND_ASSIGN(V8ValueConverterImpl
);
82 } // namespace content
84 #endif // CONTENT_RENDERER_V8_VALUE_CONVERTER_IMPL_H_