Chromium Code Reviews| 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 "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "content/common/content_export.h" | 9 #include "content/common/content_export.h" |
| 10 #include "content/public/renderer/v8_value_converter.h" | 10 #include "content/public/renderer/v8_value_converter.h" |
| 11 | 11 |
| 12 namespace base { | 12 namespace base { |
| 13 class BinaryValue; | 13 class BinaryValue; |
| 14 class DictionaryValue; | 14 class DictionaryValue; |
| 15 class ListValue; | 15 class ListValue; |
| 16 class Value; | 16 class Value; |
| 17 } | 17 } |
| 18 | 18 |
| 19 class CONTENT_EXPORT V8ValueConverterImpl : public content::V8ValueConverter { | 19 class CONTENT_EXPORT V8ValueConverterImpl : public content::V8ValueConverter { |
| 20 public: | 20 public: |
| 21 V8ValueConverterImpl(); | 21 V8ValueConverterImpl(); |
| 22 | 22 |
| 23 // Use the following setters to support additional types other than the | 23 // Use the following setters to support additional types other than the |
|
jam
2012/05/16 14:58:20
nit: no need for this comment now that it's in the
battre
2012/05/16 16:11:12
Done.
| |
| 24 // default ones. | 24 // default ones. |
| 25 bool allow_undefined() const { return allow_undefined_; } | 25 virtual bool GetUndefinedAllowed() const OVERRIDE; |
| 26 void set_allow_undefined(bool val) { allow_undefined_ = val; } | 26 virtual void SetUndefinedAllowed(bool val) OVERRIDE; |
| 27 | 27 |
|
jam
2012/05/16 14:58:20
nit: no blank lines since these are overridden met
battre
2012/05/16 16:11:12
Done.
| |
| 28 bool allow_date() const { return allow_date_; } | 28 virtual bool GetDateAllowed() const OVERRIDE; |
| 29 void set_allow_date(bool val) { allow_date_ = val; } | 29 virtual void SetDateAllowed(bool val) OVERRIDE; |
| 30 | 30 |
| 31 bool allow_regexp() const { return allow_regexp_; } | 31 virtual bool GetRegexpAllowed() const OVERRIDE; |
| 32 void set_allow_regexp(bool val) { allow_regexp_ = val; } | 32 virtual void SetRegexpAllowed(bool val) OVERRIDE; |
| 33 | 33 |
| 34 // V8ValueConverter implementation. | 34 // V8ValueConverter implementation. |
| 35 virtual v8::Handle<v8::Value> ToV8Value( | 35 virtual v8::Handle<v8::Value> ToV8Value( |
| 36 const base::Value* value, | 36 const base::Value* value, |
| 37 v8::Handle<v8::Context> context) const OVERRIDE; | 37 v8::Handle<v8::Context> context) const OVERRIDE; |
| 38 virtual base::Value* FromV8Value( | 38 virtual base::Value* FromV8Value( |
| 39 v8::Handle<v8::Value> value, | 39 v8::Handle<v8::Value> value, |
| 40 v8::Handle<v8::Context> context) const OVERRIDE; | 40 v8::Handle<v8::Context> context) const OVERRIDE; |
| 41 | 41 |
| 42 private: | 42 private: |
| 43 v8::Handle<v8::Value> ToV8ValueImpl(const base::Value* value) const; | 43 v8::Handle<v8::Value> ToV8ValueImpl(const base::Value* value) const; |
| 44 v8::Handle<v8::Value> ToV8Array(const base::ListValue* list) const; | 44 v8::Handle<v8::Value> ToV8Array(const base::ListValue* list) const; |
| 45 v8::Handle<v8::Value> ToV8Object( | 45 v8::Handle<v8::Value> ToV8Object( |
| 46 const base::DictionaryValue* dictionary) const; | 46 const base::DictionaryValue* dictionary) const; |
| 47 v8::Handle<v8::Value> ToArrayBuffer(const base::BinaryValue* value) const; | 47 v8::Handle<v8::Value> ToArrayBuffer(const base::BinaryValue* value) const; |
| 48 | 48 |
| 49 base::Value* FromV8ValueImpl(v8::Handle<v8::Value> value) const; | 49 base::Value* FromV8ValueImpl(v8::Handle<v8::Value> value) const; |
| 50 base::ListValue* FromV8Array(v8::Handle<v8::Array> array) const; | 50 base::ListValue* FromV8Array(v8::Handle<v8::Array> array) const; |
| 51 | 51 |
| 52 // This will convert objects of type ArrayBuffer or any of the | 52 // This will convert objects of type ArrayBuffer or any of the |
| 53 // ArrayBufferView subclasses. The return value will be NULL if |value| is | 53 // ArrayBufferView subclasses. The return value will be NULL if |value| is |
| 54 // not one of these types. | 54 // not one of these types. |
| 55 base::BinaryValue* FromV8Buffer(v8::Handle<v8::Value> value) const; | 55 base::BinaryValue* FromV8Buffer(v8::Handle<v8::Value> value) const; |
| 56 | 56 |
| 57 base::DictionaryValue* FromV8Object(v8::Handle<v8::Object> object) const; | 57 base::DictionaryValue* FromV8Object(v8::Handle<v8::Object> object) const; |
| 58 | 58 |
| 59 // If true, we will convert undefined JavaScript values to null. | 59 // If true, we will convert undefined JavaScript values to null. |
| 60 bool allow_undefined_; | 60 bool undefined_allowed_; |
| 61 | 61 |
| 62 // If true, we will convert Date JavaScript objects to doubles. | 62 // If true, we will convert Date JavaScript objects to doubles. |
| 63 bool allow_date_; | 63 bool date_allowed_; |
| 64 | 64 |
| 65 // If true, we will convet RegExp JavaScript objects to string. | 65 // If true, we will convet RegExp JavaScript objects to string. |
| 66 bool allow_regexp_; | 66 bool regexp_allowed_; |
| 67 }; | 67 }; |
| 68 | 68 |
| 69 #endif // CONTENT_RENDERER_V8_VALUE_CONVERTER_IMPL_H_ | 69 #endif // CONTENT_RENDERER_V8_VALUE_CONVERTER_IMPL_H_ |
| OLD | NEW |