| 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 plugins { |
| 19 namespace ppapi { |
| 16 | 20 |
| 17 class PluginModule; | 21 class PluginModule; |
| 18 | 22 |
| 19 class VarObjectClass : public Resource { | 23 class VarObjectClass : public Resource { |
| 20 public: | 24 public: |
| 21 struct Property { | 25 struct Property { |
| 22 explicit Property(const PP_ClassProperty& prop); | 26 explicit Property(const PP_ClassProperty& prop); |
| 23 | 27 |
| 24 const PP_ClassFunction method; | 28 const PP_ClassFunction method; |
| 25 const PP_ClassFunction getter; | 29 const PP_ClassFunction getter; |
| 26 const PP_ClassFunction setter; | 30 const PP_ClassFunction setter; |
| 27 const bool writable; | 31 const bool writable; |
| 28 const bool enumerable; | 32 const bool enumerable; |
| 29 }; | 33 }; |
| 30 | 34 |
| 35 struct InstanceData : public NPObject { |
| 36 InstanceData(); |
| 37 |
| 38 scoped_refptr<VarObjectClass> object_class; |
| 39 void* native_data; |
| 40 }; |
| 41 |
| 31 struct InstanceData; | 42 struct InstanceData; |
| 32 | 43 |
| 33 typedef base::hash_map<std::string, Property> PropertyMap; | 44 typedef base::hash_map<std::string, Property> PropertyMap; |
| 34 | 45 |
| 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, | 46 VarObjectClass(PluginModule* module, PP_ClassDestructor destruct, |
| 39 PP_ClassFunction invoke, PP_ClassProperty* properties); | 47 PP_ClassFunction invoke, PP_ClassProperty* properties); |
| 40 virtual ~VarObjectClass(); | 48 virtual ~VarObjectClass(); |
| 41 | 49 |
| 42 // Resource override. | 50 // Resource override. |
| 43 virtual VarObjectClass* AsVarObjectClass() { return this; } | 51 virtual VarObjectClass* AsVarObjectClass(); |
| 52 |
| 53 // Returns the PPB_Var interface for the plugin to use. |
| 54 static const PPB_Class* GetInterface(); |
| 44 | 55 |
| 45 const PropertyMap &properties() const { return properties_; } | 56 const PropertyMap &properties() const { return properties_; } |
| 46 | 57 |
| 47 PP_ClassDestructor instance_native_destructor() { | 58 PP_ClassDestructor instance_native_destructor() { |
| 48 return instance_native_destructor_; | 59 return instance_native_destructor_; |
| 49 } | 60 } |
| 50 | 61 |
| 51 PP_ClassFunction instance_invoke() { | 62 PP_ClassFunction instance_invoke() { |
| 52 return instance_invoke_; | 63 return instance_invoke_; |
| 53 } | 64 } |
| 54 | 65 |
| 55 private: | 66 private: |
| 56 PropertyMap properties_; | 67 PropertyMap properties_; |
| 57 PP_ClassDestructor instance_native_destructor_; | 68 PP_ClassDestructor instance_native_destructor_; |
| 58 PP_ClassFunction instance_invoke_; | 69 PP_ClassFunction instance_invoke_; |
| 59 | 70 |
| 60 DISALLOW_COPY_AND_ASSIGN(VarObjectClass); | 71 DISALLOW_COPY_AND_ASSIGN(VarObjectClass); |
| 61 }; | 72 }; |
| 62 | 73 |
| 63 } // namespace pepper | 74 } // namespace ppapi |
| 75 } // namespace plugins |
| 76 } // namespace webkit |
| 64 | 77 |
| 65 #endif // WEBKIT_GLUE_PLUGINS_PEPPER_CLASS_H_ | 78 #endif // WEBKIT_PLUGINS_PPAPI_CLASS_H_ |
| 66 | 79 |
| OLD | NEW |