diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-04 17:01:19 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-04 17:01:19 +0000 |
commit | 8d86f13d2e87cc58739121d40dd698122707878e (patch) | |
tree | e405675f7074a991812eeda37e48e4b265c0cb12 /content/renderer/v8_value_converter_impl.h | |
parent | 2b960d33bdcd6e390c0a9558b3793073f5659135 (diff) | |
download | chromium_src-8d86f13d2e87cc58739121d40dd698122707878e.zip chromium_src-8d86f13d2e87cc58739121d40dd698122707878e.tar.gz chromium_src-8d86f13d2e87cc58739121d40dd698122707878e.tar.bz2 |
Make V8ValueConverter be an interface and move it to content\public\renderer and put in the content namespace.
BUG=98716
Review URL: http://codereview.chromium.org/8122011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@103925 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/renderer/v8_value_converter_impl.h')
-rw-r--r-- | content/renderer/v8_value_converter_impl.h | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/content/renderer/v8_value_converter_impl.h b/content/renderer/v8_value_converter_impl.h new file mode 100644 index 0000000..dfdc001 --- /dev/null +++ b/content/renderer/v8_value_converter_impl.h @@ -0,0 +1,53 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CONTENT_RENDERER_V8_VALUE_CONVERTER_IMPL_H_ +#define CONTENT_RENDERER_V8_VALUE_CONVERTER_IMPL_H_ + +#include "base/compiler_specific.h" +#include "content/public/renderer/v8_value_converter.h" + +class V8ValueConverterImpl : public content::V8ValueConverter { + public: + V8ValueConverterImpl(); + + // Use the following setters to support additional types other than the + // default ones. + bool allow_undefined() const { return allow_undefined_; } + void set_allow_undefined(bool val) { allow_undefined_ = val; } + + bool allow_date() const { return allow_date_; } + void set_allow_date(bool val) { allow_date_ = val; } + + bool allow_regexp() const { return allow_regexp_; } + void set_allow_regexp(bool val) { allow_regexp_ = val; } + + // V8ValueConverter implementation. + virtual v8::Handle<v8::Value> ToV8Value( + base::Value* value, + v8::Handle<v8::Context> context) const OVERRIDE; + virtual base::Value* FromV8Value( + v8::Handle<v8::Value> value, + v8::Handle<v8::Context> context) const OVERRIDE; + + private: + v8::Handle<v8::Value> ToV8ValueImpl(base::Value* value) const; + v8::Handle<v8::Value> ToV8Array(base::ListValue* list) const; + v8::Handle<v8::Value> ToV8Object(base::DictionaryValue* dictionary) const; + + base::Value* FromV8ValueImpl(v8::Handle<v8::Value> value) const; + base::ListValue* FromV8Array(v8::Handle<v8::Array> array) const; + base::DictionaryValue* FromV8Object(v8::Handle<v8::Object> object) const; + + // If true, we will convert undefined JavaScript values to null. + bool allow_undefined_; + + // If true, we will convert Date JavaScript objects to doubles. + bool allow_date_; + + // If true, we will convet RegExp JavaScript objects to string. + bool allow_regexp_; +}; + +#endif // CONTENT_RENDERER_V8_VALUE_CONVERTER_IMPL_H_ |