[email protected] | 2d58238b | 2012-05-09 20:30:19 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | 8d86f13d | 2011-10-04 17:01:19 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
4 | |||||
5 | #ifndef CONTENT_RENDERER_V8_VALUE_CONVERTER_IMPL_H_ | ||||
6 | #define CONTENT_RENDERER_V8_VALUE_CONVERTER_IMPL_H_ | ||||
7 | |||||
8 | #include "base/compiler_specific.h" | ||||
[email protected] | 56b8d5c | 2011-10-07 00:28:34 | [diff] [blame] | 9 | #include "content/common/content_export.h" |
[email protected] | 8d86f13d | 2011-10-04 17:01:19 | [diff] [blame] | 10 | #include "content/public/renderer/v8_value_converter.h" |
11 | |||||
[email protected] | 040b785 | 2011-11-09 03:51:09 | [diff] [blame] | 12 | namespace base { |
[email protected] | 2d58238b | 2012-05-09 20:30:19 | [diff] [blame] | 13 | class BinaryValue; |
[email protected] | 040b785 | 2011-11-09 03:51:09 | [diff] [blame] | 14 | class DictionaryValue; |
15 | class ListValue; | ||||
16 | class Value; | ||||
17 | } | ||||
18 | |||||
[email protected] | 56b8d5c | 2011-10-07 00:28:34 | [diff] [blame] | 19 | class CONTENT_EXPORT V8ValueConverterImpl : public content::V8ValueConverter { |
[email protected] | 8d86f13d | 2011-10-04 17:01:19 | [diff] [blame] | 20 | public: |
21 | V8ValueConverterImpl(); | ||||
22 | |||||
[email protected] | 8d86f13d | 2011-10-04 17:01:19 | [diff] [blame] | 23 | // V8ValueConverter implementation. |
[email protected] | 3de391e8 | 2012-05-16 17:50:51 | [diff] [blame^] | 24 | virtual bool GetUndefinedAllowed() const OVERRIDE; |
25 | virtual void SetUndefinedAllowed(bool val) OVERRIDE; | ||||
26 | virtual bool GetDateAllowed() const OVERRIDE; | ||||
27 | virtual void SetDateAllowed(bool val) OVERRIDE; | ||||
28 | virtual bool GetRegexpAllowed() const OVERRIDE; | ||||
29 | virtual void SetRegexpAllowed(bool val) OVERRIDE; | ||||
[email protected] | 8d86f13d | 2011-10-04 17:01:19 | [diff] [blame] | 30 | virtual v8::Handle<v8::Value> ToV8Value( |
[email protected] | 83820d4 | 2011-11-12 22:03:11 | [diff] [blame] | 31 | const base::Value* value, |
[email protected] | 8d86f13d | 2011-10-04 17:01:19 | [diff] [blame] | 32 | v8::Handle<v8::Context> context) const OVERRIDE; |
33 | virtual base::Value* FromV8Value( | ||||
34 | v8::Handle<v8::Value> value, | ||||
35 | v8::Handle<v8::Context> context) const OVERRIDE; | ||||
36 | |||||
37 | private: | ||||
[email protected] | 83820d4 | 2011-11-12 22:03:11 | [diff] [blame] | 38 | v8::Handle<v8::Value> ToV8ValueImpl(const base::Value* value) const; |
39 | v8::Handle<v8::Value> ToV8Array(const base::ListValue* list) const; | ||||
40 | v8::Handle<v8::Value> ToV8Object( | ||||
41 | const base::DictionaryValue* dictionary) const; | ||||
[email protected] | 2d58238b | 2012-05-09 20:30:19 | [diff] [blame] | 42 | v8::Handle<v8::Value> ToArrayBuffer(const base::BinaryValue* value) const; |
[email protected] | 8d86f13d | 2011-10-04 17:01:19 | [diff] [blame] | 43 | |
44 | base::Value* FromV8ValueImpl(v8::Handle<v8::Value> value) const; | ||||
45 | base::ListValue* FromV8Array(v8::Handle<v8::Array> array) const; | ||||
[email protected] | 2d58238b | 2012-05-09 20:30:19 | [diff] [blame] | 46 | |
47 | // This will convert objects of type ArrayBuffer or any of the | ||||
48 | // ArrayBufferView subclasses. The return value will be NULL if |value| is | ||||
49 | // not one of these types. | ||||
50 | base::BinaryValue* FromV8Buffer(v8::Handle<v8::Value> value) const; | ||||
51 | |||||
[email protected] | 8d86f13d | 2011-10-04 17:01:19 | [diff] [blame] | 52 | base::DictionaryValue* FromV8Object(v8::Handle<v8::Object> object) const; |
53 | |||||
54 | // If true, we will convert undefined JavaScript values to null. | ||||
[email protected] | 3de391e8 | 2012-05-16 17:50:51 | [diff] [blame^] | 55 | bool undefined_allowed_; |
[email protected] | 8d86f13d | 2011-10-04 17:01:19 | [diff] [blame] | 56 | |
57 | // If true, we will convert Date JavaScript objects to doubles. | ||||
[email protected] | 3de391e8 | 2012-05-16 17:50:51 | [diff] [blame^] | 58 | bool date_allowed_; |
[email protected] | 8d86f13d | 2011-10-04 17:01:19 | [diff] [blame] | 59 | |
60 | // If true, we will convet RegExp JavaScript objects to string. | ||||
[email protected] | 3de391e8 | 2012-05-16 17:50:51 | [diff] [blame^] | 61 | bool regexp_allowed_; |
[email protected] | 8d86f13d | 2011-10-04 17:01:19 | [diff] [blame] | 62 | }; |
63 | |||||
[email protected] | 040b785 | 2011-11-09 03:51:09 | [diff] [blame] | 64 | #endif // CONTENT_RENDERER_V8_VALUE_CONVERTER_IMPL_H_ |