Roll ANGLE bc75f36:ef9d63e
[chromium-blink-merge.git] / content / renderer / v8_value_converter_impl.h
blobaffbed7353fc42638e5d0d80d63a9606a38b49b2
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 <map>
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"
15 namespace base {
16 class BinaryValue;
17 class DictionaryValue;
18 class ListValue;
19 class Value;
22 namespace content {
24 class CONTENT_EXPORT V8ValueConverterImpl : public V8ValueConverter {
25 public:
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 void SetStrategy(Strategy* strategy) OVERRIDE;
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;
41 private:
42 friend class ScopedAvoidIdentityHashForTesting;
44 class FromV8ValueState;
46 v8::Local<v8::Value> ToV8ValueImpl(v8::Isolate* isolate,
47 v8::Handle<v8::Object> creation_context,
48 const base::Value* value) const;
49 v8::Handle<v8::Value> ToV8Array(v8::Isolate* isolate,
50 v8::Handle<v8::Object> creation_context,
51 const base::ListValue* list) const;
52 v8::Handle<v8::Value> ToV8Object(
53 v8::Isolate* isolate,
54 v8::Handle<v8::Object> creation_context,
55 const base::DictionaryValue* dictionary) const;
56 v8::Handle<v8::Value> ToArrayBuffer(v8::Isolate* isolate,
57 v8::Handle<v8::Object> creation_context,
58 const base::BinaryValue* value) const;
60 base::Value* FromV8ValueImpl(FromV8ValueState* state,
61 v8::Handle<v8::Value> value,
62 v8::Isolate* isolate) const;
63 base::Value* FromV8Array(v8::Handle<v8::Array> array,
64 FromV8ValueState* state,
65 v8::Isolate* isolate) const;
67 // This will convert objects of type ArrayBuffer or any of the
68 // ArrayBufferView subclasses.
69 base::Value* FromV8ArrayBuffer(v8::Handle<v8::Object> val,
70 v8::Isolate* isolate) const;
72 base::Value* FromV8Object(v8::Handle<v8::Object> object,
73 FromV8ValueState* state,
74 v8::Isolate* isolate) const;
76 // If true, we will convert Date JavaScript objects to doubles.
77 bool date_allowed_;
79 // If true, we will convert RegExp JavaScript objects to string.
80 bool reg_exp_allowed_;
82 // If true, we will convert Function JavaScript objects to dictionaries.
83 bool function_allowed_;
85 // If true, undefined and null values are ignored when converting v8 objects
86 // into Values.
87 bool strip_null_from_objects_;
89 bool avoid_identity_hash_for_testing_;
91 // Strategy object that changes the converter's behavior.
92 Strategy* strategy_;
94 DISALLOW_COPY_AND_ASSIGN(V8ValueConverterImpl);
97 } // namespace content
99 #endif // CONTENT_RENDERER_V8_VALUE_CONVERTER_IMPL_H_