| 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 <set> |
| 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; |
| 19 } | 19 } |
| 20 | 20 |
| 21 class CONTENT_EXPORT V8ValueConverterImpl : public content::V8ValueConverter { | 21 class CONTENT_EXPORT V8ValueConverterImpl : public content::V8ValueConverter { |
| 22 public: | 22 public: |
| 23 V8ValueConverterImpl(); | 23 V8ValueConverterImpl(); |
| 24 | 24 |
| 25 // V8ValueConverter implementation. | 25 // V8ValueConverter implementation. |
| 26 virtual bool GetUndefinedAllowed() const OVERRIDE; | |
| 27 virtual void SetUndefinedAllowed(bool val) OVERRIDE; | |
| 28 virtual bool GetDateAllowed() const OVERRIDE; | |
| 29 virtual void SetDateAllowed(bool val) OVERRIDE; | 26 virtual void SetDateAllowed(bool val) OVERRIDE; |
| 30 virtual bool GetRegexpAllowed() const OVERRIDE; | 27 virtual void SetRegExpAllowed(bool val) OVERRIDE; |
| 31 virtual void SetRegexpAllowed(bool val) OVERRIDE; | 28 virtual void SetFunctionAllowed(bool val) OVERRIDE; |
| 32 virtual bool GetStripNullFromObjects() const OVERRIDE; | |
| 33 virtual void SetStripNullFromObjects(bool val) OVERRIDE; | 29 virtual void SetStripNullFromObjects(bool val) OVERRIDE; |
| 34 virtual v8::Handle<v8::Value> ToV8Value( | 30 virtual v8::Handle<v8::Value> ToV8Value( |
| 35 const base::Value* value, | 31 const base::Value* value, |
| 36 v8::Handle<v8::Context> context) const OVERRIDE; | 32 v8::Handle<v8::Context> context) const OVERRIDE; |
| 37 virtual base::Value* FromV8Value( | 33 virtual base::Value* FromV8Value( |
| 38 v8::Handle<v8::Value> value, | 34 v8::Handle<v8::Value> value, |
| 39 v8::Handle<v8::Context> context) const OVERRIDE; | 35 v8::Handle<v8::Context> context) const OVERRIDE; |
| 40 | 36 |
| 41 private: | 37 private: |
| 42 v8::Handle<v8::Value> ToV8ValueImpl(const base::Value* value) const; | 38 v8::Handle<v8::Value> ToV8ValueImpl(const base::Value* value) const; |
| 43 v8::Handle<v8::Value> ToV8Array(const base::ListValue* list) const; | 39 v8::Handle<v8::Value> ToV8Array(const base::ListValue* list) const; |
| 44 v8::Handle<v8::Value> ToV8Object( | 40 v8::Handle<v8::Value> ToV8Object( |
| 45 const base::DictionaryValue* dictionary) const; | 41 const base::DictionaryValue* dictionary) const; |
| 46 v8::Handle<v8::Value> ToArrayBuffer(const base::BinaryValue* value) const; | 42 v8::Handle<v8::Value> ToArrayBuffer(const base::BinaryValue* value) const; |
| 47 | 43 |
| 48 base::Value* FromV8ValueImpl(v8::Handle<v8::Value> value, | 44 base::Value* FromV8ValueImpl(v8::Handle<v8::Value> value, |
| 49 std::set<int>* unique_set) const; | 45 std::set<int>* unique_set) const; |
| 50 base::Value* FromV8Array(v8::Handle<v8::Array> array, | 46 base::Value* FromV8Array(v8::Handle<v8::Array> array, |
| 51 std::set<int>* unique_set) const; | 47 std::set<int>* unique_set) const; |
| 52 | 48 |
| 53 // This will convert objects of type ArrayBuffer or any of the | 49 // This will convert objects of type ArrayBuffer or any of the |
| 54 // ArrayBufferView subclasses. The return value will be NULL if |value| is | 50 // ArrayBufferView subclasses. The return value will be NULL if |value| is |
| 55 // not one of these types. | 51 // not one of these types. |
| 56 base::BinaryValue* FromV8Buffer(v8::Handle<v8::Value> value) const; | 52 base::BinaryValue* FromV8Buffer(v8::Handle<v8::Value> value) const; |
| 57 | 53 |
| 58 base::Value* FromV8Object(v8::Handle<v8::Object> object, | 54 base::Value* FromV8Object(v8::Handle<v8::Object> object, |
| 59 std::set<int>* unique_set) const; | 55 std::set<int>* unique_set) const; |
| 60 | 56 |
| 61 // If true, we will convert undefined JavaScript values to null. | |
| 62 bool undefined_allowed_; | |
| 63 | |
| 64 // If true, we will convert Date JavaScript objects to doubles. | 57 // If true, we will convert Date JavaScript objects to doubles. |
| 65 bool date_allowed_; | 58 bool date_allowed_; |
| 66 | 59 |
| 67 // If true, we will convet RegExp JavaScript objects to string. | 60 // If true, we will convert RegExp JavaScript objects to string. |
| 68 bool regexp_allowed_; | 61 bool reg_exp_allowed_; |
| 62 |
| 63 // If true, we will convert Function JavaScript objects to dictionaries. |
| 64 bool function_allowed_; |
| 69 | 65 |
| 70 // If true, undefined and null values are ignored when converting v8 objects | 66 // If true, undefined and null values are ignored when converting v8 objects |
| 71 // into Values. | 67 // into Values. |
| 72 bool strip_null_from_objects_; | 68 bool strip_null_from_objects_; |
| 73 }; | 69 }; |
| 74 | 70 |
| 75 #endif // CONTENT_RENDERER_V8_VALUE_CONVERTER_IMPL_H_ | 71 #endif // CONTENT_RENDERER_V8_VALUE_CONVERTER_IMPL_H_ |
| OLD | NEW |