Chromium Code Reviews| 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..0d8236548522848c8376ecdc7d0e9f8f9a347751 100644 |
| --- a/content/public/renderer/v8_value_converter.h |
| +++ b/content/public/renderer/v8_value_converter.h |
| @@ -30,8 +30,19 @@ class CONTENT_EXPORT 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; |
| + |
| + enum UndefinedValueBehavior { |
| + // Treat undefined values as errors. This is the default behavior. |
| + TREAT_AS_ERROR, |
|
not at google - send to devlin
2012/09/11 11:50:11
The existence of "treat as error" only makes if tr
koz (OOO until 15th September)
2012/09/12 02:08:28
As discussed, seeing as this logs errors to STDERR
|
| + |
| + // Treat undefined values as inconvertible and omit them from the result. |
| + OMIT, |
| + |
| + // Convert undefined values to null. |
| + CONVERT_TO_NULL |
| + }; |
| + virtual UndefinedValueBehavior GetUndefinedValueBehavior() const = 0; |
| + virtual void SetUndefinedValueBehavior(UndefinedValueBehavior val) = 0; |
| virtual bool GetDateAllowed() const = 0; |
| virtual void SetDateAllowed(bool val) = 0; |
| @@ -43,16 +54,24 @@ class CONTENT_EXPORT V8ValueConverter { |
| virtual bool GetStripNullFromObjects() const = 0; |
| 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). |
|
koz (OOO until 15th September)
2012/09/12 02:08:28
where unsupported types -> where elements that hav
|
| + // |
| + // 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 |
|
koz (OOO until 15th September)
2012/09/12 02:08:28
Perhaps better phrased as:
If an object throws wh
|
| + // converted to Value(TYPE_NULL). |
| virtual base::Value* FromV8Value(v8::Handle<v8::Value> value, |
| v8::Handle<v8::Context> context) const = 0; |
| }; |