OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_RENDERER_V8_VALUE_CONVERTER_IMPL_H_ | 5 #ifndef CONTENT_RENDERER_V8_VALUE_CONVERTER_IMPL_H_ |
6 #define CONTENT_RENDERER_V8_VALUE_CONVERTER_IMPL_H_ | 6 #define CONTENT_RENDERER_V8_VALUE_CONVERTER_IMPL_H_ |
7 | 7 |
8 #include <set> | 8 #include <map> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "content/common/content_export.h" | 11 #include "content/common/content_export.h" |
12 #include "content/public/renderer/v8_value_converter.h" | 12 #include "content/public/renderer/v8_value_converter.h" |
13 | 13 |
14 namespace base { | 14 namespace base { |
15 class BinaryValue; | 15 class BinaryValue; |
16 class DictionaryValue; | 16 class DictionaryValue; |
17 class ListValue; | 17 class ListValue; |
18 class Value; | 18 class Value; |
(...skipping 11 matching lines...) Expand all Loading... | |
30 virtual void SetFunctionAllowed(bool val) OVERRIDE; | 30 virtual void SetFunctionAllowed(bool val) OVERRIDE; |
31 virtual void SetStripNullFromObjects(bool val) OVERRIDE; | 31 virtual void SetStripNullFromObjects(bool val) OVERRIDE; |
32 virtual v8::Handle<v8::Value> ToV8Value( | 32 virtual v8::Handle<v8::Value> ToV8Value( |
33 const base::Value* value, | 33 const base::Value* value, |
34 v8::Handle<v8::Context> context) const OVERRIDE; | 34 v8::Handle<v8::Context> context) const OVERRIDE; |
35 virtual base::Value* FromV8Value( | 35 virtual base::Value* FromV8Value( |
36 v8::Handle<v8::Value> value, | 36 v8::Handle<v8::Value> value, |
37 v8::Handle<v8::Context> context) const OVERRIDE; | 37 v8::Handle<v8::Context> context) const OVERRIDE; |
38 | 38 |
39 private: | 39 private: |
40 typedef std::multimap<int, v8::Handle<v8::Object> > HashToHandleMap; | |
41 | |
40 v8::Handle<v8::Value> ToV8ValueImpl(const base::Value* value) const; | 42 v8::Handle<v8::Value> ToV8ValueImpl(const base::Value* value) const; |
41 v8::Handle<v8::Value> ToV8Array(const base::ListValue* list) const; | 43 v8::Handle<v8::Value> ToV8Array(const base::ListValue* list) const; |
42 v8::Handle<v8::Value> ToV8Object( | 44 v8::Handle<v8::Value> ToV8Object( |
43 const base::DictionaryValue* dictionary) const; | 45 const base::DictionaryValue* dictionary) const; |
44 v8::Handle<v8::Value> ToArrayBuffer(const base::BinaryValue* value) const; | 46 v8::Handle<v8::Value> ToArrayBuffer(const base::BinaryValue* value) const; |
45 | 47 |
46 base::Value* FromV8ValueImpl(v8::Handle<v8::Value> value, | 48 base::Value* FromV8ValueImpl(v8::Handle<v8::Value> value, |
47 std::set<int>* unique_set) const; | 49 HashToHandleMap* unique_map) const; |
48 base::Value* FromV8Array(v8::Handle<v8::Array> array, | 50 base::Value* FromV8Array(v8::Handle<v8::Array> array, |
49 std::set<int>* unique_set) const; | 51 HashToHandleMap* unique_map) const; |
50 | 52 |
51 // This will convert objects of type ArrayBuffer or any of the | 53 // This will convert objects of type ArrayBuffer or any of the |
52 // ArrayBufferView subclasses. The return value will be NULL if |value| is | 54 // ArrayBufferView subclasses. The return value will be NULL if |value| is |
53 // not one of these types. | 55 // not one of these types. |
54 base::BinaryValue* FromV8Buffer(v8::Handle<v8::Value> value) const; | 56 base::BinaryValue* FromV8Buffer(v8::Handle<v8::Value> value) const; |
55 | 57 |
56 base::Value* FromV8Object(v8::Handle<v8::Object> object, | 58 base::Value* FromV8Object(v8::Handle<v8::Object> object, |
57 std::set<int>* unique_set) const; | 59 HashToHandleMap* unique_map) const; |
60 | |
61 // If |handle| is not in |map|, then adds it to |map| and returns true. | |
eaugusti
2013/03/14 17:21:09
nit: "add" and "return" (singular).
vabr (Chromium)
2013/03/14 17:59:37
Done.
| |
62 // Otherwise does nothing and returns false. | |
63 static bool UpdateAndCheckUniqueness(HashToHandleMap* map, | |
64 v8::Handle<v8::Object> handle); | |
58 | 65 |
59 // If true, we will convert Date JavaScript objects to doubles. | 66 // If true, we will convert Date JavaScript objects to doubles. |
60 bool date_allowed_; | 67 bool date_allowed_; |
61 | 68 |
62 // If true, we will convert RegExp JavaScript objects to string. | 69 // If true, we will convert RegExp JavaScript objects to string. |
63 bool reg_exp_allowed_; | 70 bool reg_exp_allowed_; |
64 | 71 |
65 // If true, we will convert Function JavaScript objects to dictionaries. | 72 // If true, we will convert Function JavaScript objects to dictionaries. |
66 bool function_allowed_; | 73 bool function_allowed_; |
67 | 74 |
68 // If true, undefined and null values are ignored when converting v8 objects | 75 // If true, undefined and null values are ignored when converting v8 objects |
69 // into Values. | 76 // into Values. |
70 bool strip_null_from_objects_; | 77 bool strip_null_from_objects_; |
71 }; | 78 }; |
72 | 79 |
73 } // namespace content | 80 } // namespace content |
74 | 81 |
75 #endif // CONTENT_RENDERER_V8_VALUE_CONVERTER_IMPL_H_ | 82 #endif // CONTENT_RENDERER_V8_VALUE_CONVERTER_IMPL_H_ |
OLD | NEW |