Index: webkit/glue/plugins/pepper_var.cc |
=================================================================== |
--- webkit/glue/plugins/pepper_var.cc (revision 48067) |
+++ webkit/glue/plugins/pepper_var.cc (working copy) |
@@ -14,9 +14,6 @@ |
#include "webkit/glue/plugins/pepper_string.h" |
#include "v8/include/v8.h" |
-// Uncomment to enable catching JS exceptions |
-// #define HAVE_WEBBINDINGS_EXCEPTION_HANDLER 1 |
- |
using WebKit::WebBindings; |
namespace pepper { |
@@ -32,15 +29,11 @@ |
class TryCatch { |
public: |
TryCatch(PP_Var* exception) : exception_(exception) { |
-#ifdef HAVE_WEBBINDINGS_EXCEPTION_HANDLER |
WebBindings::pushExceptionHandler(&TryCatch::Catch, this); |
-#endif |
} |
~TryCatch() { |
-#ifdef HAVE_WEBBINDINGS_EXCEPTION_HANDLER |
WebBindings::popExceptionHandler(); |
-#endif |
} |
bool HasException() const { |
@@ -90,12 +83,6 @@ |
return reinterpret_cast<NPObject*>(var.value.as_id); |
} |
-NPObject* GetNPObject(PP_Var var) { |
- if (var.type != PP_VarType_Object) |
- return NULL; |
- return GetNPObjectUnchecked(var); |
-} |
- |
// Returns a PP_Var that corresponds to the given NPVariant. The contents of |
// the NPVariant will be copied unless the NPVariant corresponds to an object. |
PP_Var NPVariantToPPVar(const NPVariant* variant) { |
@@ -417,9 +404,39 @@ |
bool WrapperClass_Enumerate(NPObject* object, NPIdentifier** values, |
uint32_t* count) { |
- // TODO(darin): Implement this method! |
- WebBindings::setException(object, kUnableToGetAllPropertiesException); |
- return false; |
+ WrapperObject* wrapper = ToWrapper(object); |
+ |
+ uint32_t property_count = 0; |
+ PP_Var* properties = NULL; |
+ PP_Var exception = PP_MakeVoid(); |
+ wrapper->ppp_class->GetAllPropertyNames(wrapper->ppp_class_data, |
+ &property_count, |
+ &properties, |
+ &exception); |
+ |
+ bool rv; |
+ if (exception.type == PP_VarType_Void) { |
+ rv = true; |
+ if (property_count == 0) { |
+ *values = NULL; |
+ *count = 0; |
+ } else { |
+ *values = static_cast<NPIdentifier*>( |
+ malloc(sizeof(NPIdentifier) * property_count)); |
+ *count = property_count; |
+ for (uint32_t i = 0; i < property_count; ++i) |
+ (*values)[i] = PPVarToNPIdentifier(properties[i]); |
+ } |
+ } else { |
+ rv = false; |
+ ThrowException(object, exception); |
+ Release(exception); |
+ } |
+ |
+ for (uint32_t i = 0; i < property_count; ++i) |
+ Release(properties[i]); |
+ free(properties); |
+ return rv; |
} |
bool WrapperClass_Construct(NPObject* object, const NPVariant* argv, |
@@ -591,12 +608,35 @@ |
uint32_t* property_count, |
PP_Var** properties, |
PP_Var* exception) { |
+ *properties = NULL; |
+ *property_count = 0; |
+ |
TryCatch try_catch(exception); |
if (try_catch.HasException()) |
return; |
- // TODO(darin): Implement this method! |
- try_catch.SetException(kUnableToGetAllPropertiesException); |
+ NPObject* object = GetNPObject(var); |
+ if (!object) { |
+ try_catch.SetException(kInvalidObjectException); |
+ return; |
+ } |
+ |
+ NPIdentifier* identifiers = NULL; |
+ uint32_t count = 0; |
+ if (!WebBindings::enumerate(NULL, object, &identifiers, &count)) { |
+ if (!try_catch.HasException()) |
+ try_catch.SetException(kUnableToGetAllPropertiesException); |
+ return; |
+ } |
+ |
+ if (count == 0) |
+ return; |
+ |
+ *property_count = count; |
+ *properties = static_cast<PP_Var*>(malloc(sizeof(PP_Var) * count)); |
+ for (uint32_t i = 0; i < count; ++i) |
+ (*properties)[i] = NPIdentifierToPPVar(identifiers[i]); |
+ free(identifiers); |
} |
void SetProperty(PP_Var var, |
@@ -799,4 +839,10 @@ |
return ret; |
} |
+NPObject* GetNPObject(PP_Var var) { |
+ if (var.type != PP_VarType_Object) |
+ return NULL; |
+ return GetNPObjectUnchecked(var); |
+} |
+ |
} // namespace pepper |