Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(373)

Unified Diff: content/public/renderer/v8_value_converter.h

Issue 10890002: Make V8ValueConverter.FromV8Value behave similarly to JSON.stringify (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: no more function Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/public/renderer/v8_value_converter.h
diff --git a/content/public/renderer/v8_value_converter.h b/content/public/renderer/v8_value_converter.h
index be45ea9d3f56325e181ce057cbe10026f2f2e7ca..b71b32dae3ab6563f5040485fcd9bc8b8d340364 100644
--- a/content/public/renderer/v8_value_converter.h
+++ b/content/public/renderer/v8_value_converter.h
@@ -28,31 +28,48 @@ class CONTENT_EXPORT V8ValueConverter {
virtual ~V8ValueConverter() {}
- // Use the following setters to support additional types other than the
- // default ones.
- virtual bool GetUndefinedAllowed() const = 0;
- virtual void SetUndefinedAllowed(bool val) = 0;
-
- virtual bool GetDateAllowed() const = 0;
+ // If true, Date objects are converted into DoubleValues with the number of
+ // seconds since Unix epoch.
+ //
+ // Otherwise they are converted into DictionaryValues with whatever additional
+ // properties has been set on them.
virtual void SetDateAllowed(bool val) = 0;
- virtual bool GetRegexpAllowed() const = 0;
- virtual void SetRegexpAllowed(bool val) = 0;
+ // If true, RegExp objects are converted into StringValues with the regular
+ // expression between / and /, for example "/ab?c/".
+ //
+ // Otherwise they are converted into DictionaryValues with whatever additional
+ // properties has been set on them.
+ virtual void SetRegExpAllowed(bool val) = 0;
+
+ // If true, Function objects are converted into DictionaryValues with whatever
+ // additional properties has been set on them.
+ //
+ // Otherwise they are treated as unsupported, see FromV8Value.
+ virtual void SetFunctionAllowed(bool val) = 0;
- // Gets/sets whether to treat undefined or null in objects as nonexistent.
- virtual bool GetStripNullFromObjects() const = 0;
+ // If true, null values are stripped from objects. This is often useful when
+ // converting arguments to extension APIs.
virtual void SetStripNullFromObjects(bool val) = 0;
- // Converts Value to v8::Value. Unsupported types are replaced with null.
- // If an array or object throws while setting a value, that property or item
- // is skipped, leaving a hole in the case of arrays.
+ // Converts a base::Value to a v8::Value.
+ //
+ // Unsupported types are replaced with null. If an array or object throws
+ // while setting a value, that property or item is skipped, leaving a hole in
+ // the case of arrays.
virtual v8::Handle<v8::Value> ToV8Value(
const base::Value* value,
v8::Handle<v8::Context> context) const = 0;
- // Converts v8::Value to Value. Unsupported types are replaced with null.
- // If an array or object throws while getting a value, that property or item
- // is replaced with null.
+ // Converts a v8::Value to base::Value.
+ //
+ // Unsupported types (unless explicitly configured) are not converted, so
+ // this method may return NULL -- the exception is when converting arrays,
+ // where unsupported types are converted to Value(TYPE_NULL).
+ //
+ // Likewise, if an object throws while converting a property it will not be
+ // converted, whereas if an array throws while converting an item it will be
+ // converted to Value(TYPE_NULL).
virtual base::Value* FromV8Value(v8::Handle<v8::Value> value,
v8::Handle<v8::Context> context) const = 0;
};
« no previous file with comments | « chrome/test/data/extensions/api_test/settings/simple_test/background.js ('k') | content/renderer/render_view_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698