[content shell] implement testRunner.overridePreference
[chromium-blink-merge.git] / content / renderer / v8_value_converter_impl.h
blob421c95a89c2de0f07384c7bd9c1875b90c499fd7
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_
8 #include <set>
10 #include "base/compiler_specific.h"
11 #include "content/common/content_export.h"
12 #include "content/public/renderer/v8_value_converter.h"
14 namespace base {
15 class BinaryValue;
16 class DictionaryValue;
17 class ListValue;
18 class Value;
21 namespace content {
23 class CONTENT_EXPORT V8ValueConverterImpl : public V8ValueConverter {
24 public:
25 V8ValueConverterImpl();
27 // V8ValueConverter implementation.
28 virtual void SetDateAllowed(bool val) OVERRIDE;
29 virtual void SetRegExpAllowed(bool val) OVERRIDE;
30 virtual void SetFunctionAllowed(bool val) OVERRIDE;
31 virtual void SetStripNullFromObjects(bool val) OVERRIDE;
32 virtual v8::Handle<v8::Value> ToV8Value(
33 const base::Value* value,
34 v8::Handle<v8::Context> context) const OVERRIDE;
35 virtual base::Value* FromV8Value(
36 v8::Handle<v8::Value> value,
37 v8::Handle<v8::Context> context) const OVERRIDE;
39 private:
40 v8::Handle<v8::Value> ToV8ValueImpl(const base::Value* value) const;
41 v8::Handle<v8::Value> ToV8Array(const base::ListValue* list) const;
42 v8::Handle<v8::Value> ToV8Object(
43 const base::DictionaryValue* dictionary) const;
44 v8::Handle<v8::Value> ToArrayBuffer(const base::BinaryValue* value) const;
46 base::Value* FromV8ValueImpl(v8::Handle<v8::Value> value,
47 std::set<int>* unique_set) const;
48 base::Value* FromV8Array(v8::Handle<v8::Array> array,
49 std::set<int>* unique_set) const;
51 // This will convert objects of type ArrayBuffer or any of the
52 // ArrayBufferView subclasses. The return value will be NULL if |value| is
53 // not one of these types.
54 base::BinaryValue* FromV8Buffer(v8::Handle<v8::Value> value) const;
56 base::Value* FromV8Object(v8::Handle<v8::Object> object,
57 std::set<int>* unique_set) const;
59 // If true, we will convert Date JavaScript objects to doubles.
60 bool date_allowed_;
62 // If true, we will convert RegExp JavaScript objects to string.
63 bool reg_exp_allowed_;
65 // If true, we will convert Function JavaScript objects to dictionaries.
66 bool function_allowed_;
68 // If true, undefined and null values are ignored when converting v8 objects
69 // into Values.
70 bool strip_null_from_objects_;
73 } // namespace content
75 #endif // CONTENT_RENDERER_V8_VALUE_CONVERTER_IMPL_H_