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