blob: 7f9baea33ac547d9773af5c5a8874ea6cb09c3ae [file] [log] [blame]
[email protected]2d58238b2012-05-09 20:30:191// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]8d86f13d2011-10-04 17:01:192// 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]56b8d5c2011-10-07 00:28:349#include "content/common/content_export.h"
[email protected]8d86f13d2011-10-04 17:01:1910#include "content/public/renderer/v8_value_converter.h"
11
[email protected]040b7852011-11-09 03:51:0912namespace base {
[email protected]2d58238b2012-05-09 20:30:1913class BinaryValue;
[email protected]040b7852011-11-09 03:51:0914class DictionaryValue;
15class ListValue;
16class Value;
17}
18
[email protected]56b8d5c2011-10-07 00:28:3419class CONTENT_EXPORT V8ValueConverterImpl : public content::V8ValueConverter {
[email protected]8d86f13d2011-10-04 17:01:1920 public:
21 V8ValueConverterImpl();
22
[email protected]8d86f13d2011-10-04 17:01:1923 // V8ValueConverter implementation.
[email protected]3de391e82012-05-16 17:50:5124 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]8d86f13d2011-10-04 17:01:1930 virtual v8::Handle<v8::Value> ToV8Value(
[email protected]83820d42011-11-12 22:03:1131 const base::Value* value,
[email protected]8d86f13d2011-10-04 17:01:1932 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]83820d42011-11-12 22:03:1138 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]2d58238b2012-05-09 20:30:1942 v8::Handle<v8::Value> ToArrayBuffer(const base::BinaryValue* value) const;
[email protected]8d86f13d2011-10-04 17:01:1943
44 base::Value* FromV8ValueImpl(v8::Handle<v8::Value> value) const;
45 base::ListValue* FromV8Array(v8::Handle<v8::Array> array) const;
[email protected]2d58238b2012-05-09 20:30:1946
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]8d86f13d2011-10-04 17:01:1952 base::DictionaryValue* FromV8Object(v8::Handle<v8::Object> object) const;
53
54 // If true, we will convert undefined JavaScript values to null.
[email protected]3de391e82012-05-16 17:50:5155 bool undefined_allowed_;
[email protected]8d86f13d2011-10-04 17:01:1956
57 // If true, we will convert Date JavaScript objects to doubles.
[email protected]3de391e82012-05-16 17:50:5158 bool date_allowed_;
[email protected]8d86f13d2011-10-04 17:01:1959
60 // If true, we will convet RegExp JavaScript objects to string.
[email protected]3de391e82012-05-16 17:50:5161 bool regexp_allowed_;
[email protected]8d86f13d2011-10-04 17:01:1962};
63
[email protected]040b7852011-11-09 03:51:0964#endif // CONTENT_RENDERER_V8_VALUE_CONVERTER_IMPL_H_