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 CONTENT_RENDERER_PEPPER_PLUGIN_OBJECT_H_ | 5 #ifndef CONTENT_RENDERER_PEPPER_PLUGIN_OBJECT_H_ |
6 #define CONTENT_RENDERER_PEPPER_PLUGIN_OBJECT_H_ | 6 #define CONTENT_RENDERER_PEPPER_PLUGIN_OBJECT_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 | 25 |
26 // A PluginObject is a JS-accessible object implemented by the plugin. | 26 // A PluginObject is a JS-accessible object implemented by the plugin. |
27 // | 27 // |
28 // In contrast, a var of type PP_VARTYPE_OBJECT is a reference to a JS object, | 28 // In contrast, a var of type PP_VARTYPE_OBJECT is a reference to a JS object, |
29 // which might be implemented by the plugin (here) or by the JS engine. | 29 // which might be implemented by the plugin (here) or by the JS engine. |
30 class PluginObject : public gin::Wrappable<PluginObject>, | 30 class PluginObject : public gin::Wrappable<PluginObject>, |
31 public gin::NamedPropertyInterceptor { | 31 public gin::NamedPropertyInterceptor { |
32 public: | 32 public: |
33 static gin::WrapperInfo kWrapperInfo; | 33 static gin::WrapperInfo kWrapperInfo; |
34 | 34 |
35 virtual ~PluginObject(); | 35 ~PluginObject() override; |
36 | 36 |
37 // Returns the PluginObject which is contained in the given v8 object, or NULL | 37 // Returns the PluginObject which is contained in the given v8 object, or NULL |
38 // if the object isn't backed by a PluginObject. | 38 // if the object isn't backed by a PluginObject. |
39 static PluginObject* FromV8Object(v8::Isolate* isolate, | 39 static PluginObject* FromV8Object(v8::Isolate* isolate, |
40 v8::Handle<v8::Object> v8_object); | 40 v8::Handle<v8::Object> v8_object); |
41 | 41 |
42 // Allocates a new PluginObject and returns it as a PP_Var with a | 42 // Allocates a new PluginObject and returns it as a PP_Var with a |
43 // refcount of 1. | 43 // refcount of 1. |
44 static PP_Var Create(PepperPluginInstanceImpl* instance, | 44 static PP_Var Create(PepperPluginInstanceImpl* instance, |
45 const PPP_Class_Deprecated* ppp_class, | 45 const PPP_Class_Deprecated* ppp_class, |
46 void* ppp_class_data); | 46 void* ppp_class_data); |
47 | 47 |
48 // gin::NamedPropertyInterceptor | 48 // gin::NamedPropertyInterceptor |
49 virtual v8::Local<v8::Value> GetNamedProperty( | 49 v8::Local<v8::Value> GetNamedProperty(v8::Isolate* isolate, |
50 v8::Isolate* isolate, | 50 const std::string& property) override; |
51 const std::string& property) override; | 51 bool SetNamedProperty(v8::Isolate* isolate, |
52 virtual bool SetNamedProperty(v8::Isolate* isolate, | 52 const std::string& property, |
53 const std::string& property, | 53 v8::Local<v8::Value> value) override; |
54 v8::Local<v8::Value> value) override; | 54 std::vector<std::string> EnumerateNamedProperties( |
55 virtual std::vector<std::string> EnumerateNamedProperties( | |
56 v8::Isolate* isolate) override; | 55 v8::Isolate* isolate) override; |
57 | 56 |
58 const PPP_Class_Deprecated* ppp_class() { return ppp_class_; } | 57 const PPP_Class_Deprecated* ppp_class() { return ppp_class_; } |
59 void* ppp_class_data() { return ppp_class_data_; } | 58 void* ppp_class_data() { return ppp_class_data_; } |
60 | 59 |
61 // Called when the instance is destroyed. | 60 // Called when the instance is destroyed. |
62 void InstanceDeleted(); | 61 void InstanceDeleted(); |
63 | 62 |
64 private: | 63 private: |
65 PluginObject(PepperPluginInstanceImpl* instance, | 64 PluginObject(PepperPluginInstanceImpl* instance, |
66 const PPP_Class_Deprecated* ppp_class, | 65 const PPP_Class_Deprecated* ppp_class, |
67 void* ppp_class_data); | 66 void* ppp_class_data); |
68 | 67 |
69 // gin::Wrappable | 68 // gin::Wrappable |
70 virtual gin::ObjectTemplateBuilder GetObjectTemplateBuilder( | 69 gin::ObjectTemplateBuilder GetObjectTemplateBuilder( |
71 v8::Isolate* isolate) override; | 70 v8::Isolate* isolate) override; |
72 | 71 |
73 // Helper method to get named properties. | 72 // Helper method to get named properties. |
74 v8::Local<v8::Value> GetPropertyOrMethod(v8::Isolate* isolate, | 73 v8::Local<v8::Value> GetPropertyOrMethod(v8::Isolate* isolate, |
75 PP_Var identifier_var); | 74 PP_Var identifier_var); |
76 | 75 |
77 void Call(const std::string& identifier, gin::Arguments* args); | 76 void Call(const std::string& identifier, gin::Arguments* args); |
78 | 77 |
79 PepperPluginInstanceImpl* instance_; | 78 PepperPluginInstanceImpl* instance_; |
80 | 79 |
81 const PPP_Class_Deprecated* ppp_class_; | 80 const PPP_Class_Deprecated* ppp_class_; |
82 void* ppp_class_data_; | 81 void* ppp_class_data_; |
83 | 82 |
84 base::WeakPtrFactory<PluginObject> weak_factory_; | 83 base::WeakPtrFactory<PluginObject> weak_factory_; |
85 | 84 |
86 DISALLOW_COPY_AND_ASSIGN(PluginObject); | 85 DISALLOW_COPY_AND_ASSIGN(PluginObject); |
87 }; | 86 }; |
88 | 87 |
89 } // namespace content | 88 } // namespace content |
90 | 89 |
91 #endif // CONTENT_RENDERER_PEPPER_PLUGIN_OBJECT_H_ | 90 #endif // CONTENT_RENDERER_PEPPER_PLUGIN_OBJECT_H_ |
OLD | NEW |