| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef WEBKIT_GLUE_PLUGINS_PEPPER_CLASS_H_ | 5 #ifndef WEBKIT_PLUGINS_PPAPI_CLASS_H_ |
| 6 #define WEBKIT_GLUE_PLUGINS_PEPPER_CLASS_H_ | 6 #define WEBKIT_PLUGINS_PPAPI_CLASS_H_ |
| 7 | 7 |
| 8 #include "webkit/glue/plugins/pepper_resource.h" | 8 #include "webkit/plugins/ppapi/resource.h" |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/hash_tables.h" | 12 #include "base/hash_tables.h" |
| 13 #include "base/ref_counted.h" |
| 13 #include "ppapi/c/ppb_class.h" | 14 #include "ppapi/c/ppb_class.h" |
| 15 #include "third_party/npapi/bindings/npruntime.h" |
| 14 | 16 |
| 15 namespace pepper { | 17 namespace webkit { |
| 18 namespace ppapi { |
| 16 | 19 |
| 17 class PluginModule; | 20 class PluginModule; |
| 18 | 21 |
| 19 class VarObjectClass : public Resource { | 22 class VarObjectClass : public Resource { |
| 20 public: | 23 public: |
| 21 struct Property { | 24 struct Property { |
| 22 explicit Property(const PP_ClassProperty& prop); | 25 explicit Property(const PP_ClassProperty& prop); |
| 23 | 26 |
| 24 const PP_ClassFunction method; | 27 const PP_ClassFunction method; |
| 25 const PP_ClassFunction getter; | 28 const PP_ClassFunction getter; |
| 26 const PP_ClassFunction setter; | 29 const PP_ClassFunction setter; |
| 27 const bool writable; | 30 const bool writable; |
| 28 const bool enumerable; | 31 const bool enumerable; |
| 29 }; | 32 }; |
| 30 | 33 |
| 34 struct InstanceData : public NPObject { |
| 35 InstanceData(); |
| 36 |
| 37 scoped_refptr<VarObjectClass> object_class; |
| 38 void* native_data; |
| 39 }; |
| 40 |
| 31 struct InstanceData; | 41 struct InstanceData; |
| 32 | 42 |
| 33 typedef base::hash_map<std::string, Property> PropertyMap; | 43 typedef base::hash_map<std::string, Property> PropertyMap; |
| 34 | 44 |
| 35 // Returns the PPB_Var interface for the plugin to use. | |
| 36 static const PPB_Class* GetInterface(); | |
| 37 | |
| 38 VarObjectClass(PluginModule* module, PP_ClassDestructor destruct, | 45 VarObjectClass(PluginModule* module, PP_ClassDestructor destruct, |
| 39 PP_ClassFunction invoke, PP_ClassProperty* properties); | 46 PP_ClassFunction invoke, PP_ClassProperty* properties); |
| 40 virtual ~VarObjectClass(); | 47 virtual ~VarObjectClass(); |
| 41 | 48 |
| 42 // Resource override. | 49 // Resource override. |
| 43 virtual VarObjectClass* AsVarObjectClass() { return this; } | 50 virtual VarObjectClass* AsVarObjectClass(); |
| 51 |
| 52 // Returns the PPB_Var interface for the plugin to use. |
| 53 static const PPB_Class* GetInterface(); |
| 44 | 54 |
| 45 const PropertyMap &properties() const { return properties_; } | 55 const PropertyMap &properties() const { return properties_; } |
| 46 | 56 |
| 47 PP_ClassDestructor instance_native_destructor() { | 57 PP_ClassDestructor instance_native_destructor() { |
| 48 return instance_native_destructor_; | 58 return instance_native_destructor_; |
| 49 } | 59 } |
| 50 | 60 |
| 51 PP_ClassFunction instance_invoke() { | 61 PP_ClassFunction instance_invoke() { |
| 52 return instance_invoke_; | 62 return instance_invoke_; |
| 53 } | 63 } |
| 54 | 64 |
| 55 private: | 65 private: |
| 56 PropertyMap properties_; | 66 PropertyMap properties_; |
| 57 PP_ClassDestructor instance_native_destructor_; | 67 PP_ClassDestructor instance_native_destructor_; |
| 58 PP_ClassFunction instance_invoke_; | 68 PP_ClassFunction instance_invoke_; |
| 59 | 69 |
| 60 DISALLOW_COPY_AND_ASSIGN(VarObjectClass); | 70 DISALLOW_COPY_AND_ASSIGN(VarObjectClass); |
| 61 }; | 71 }; |
| 62 | 72 |
| 63 } // namespace pepper | 73 } // namespace ppapi |
| 74 } // namespace webkit |
| 64 | 75 |
| 65 #endif // WEBKIT_GLUE_PLUGINS_PEPPER_CLASS_H_ | 76 #endif // WEBKIT_PLUGINS_PPAPI_CLASS_H_ |
| 66 | 77 |
| OLD | NEW |