[safe_browsing] Remove unused ContainsBrowseUrl() parameter.
[chromium-blink-merge.git] / content / renderer / pepper / plugin_object.h
blob62ffd2ebfbdc6806af5978a1c89a6891e19b699f
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.
5 #ifndef CONTENT_RENDERER_PEPPER_PLUGIN_OBJECT_H_
6 #define CONTENT_RENDERER_PEPPER_PLUGIN_OBJECT_H_
8 #include <string>
10 #include "base/basictypes.h"
12 struct PP_Var;
13 struct PPP_Class_Deprecated;
14 typedef struct NPObject NPObject;
15 typedef struct _NPVariant NPVariant;
17 namespace content {
19 class PepperPluginInstanceImpl;
21 // A PluginObject is a JS-accessible object implemented by the plugin.
23 // In contrast, a var of type PP_VARTYPE_OBJECT is a reference to a JS object,
24 // which might be implemented by the plugin (here) or by the JS engine.
25 class PluginObject {
26 public:
27 virtual ~PluginObject();
29 // Allocates a new PluginObject and returns it as a PP_Var with a
30 // refcount of 1.
31 static PP_Var Create(PepperPluginInstanceImpl* instance,
32 const PPP_Class_Deprecated* ppp_class,
33 void* ppp_class_data);
35 PepperPluginInstanceImpl* instance() const { return instance_; }
37 const PPP_Class_Deprecated* ppp_class() { return ppp_class_; }
38 void* ppp_class_data() {
39 return ppp_class_data_;
42 NPObject* GetNPObject() const;
44 // Returns true if the given var is an object implemented by the same plugin
45 // that owns the var object, and that the class matches. If it matches,
46 // returns true and places the class data into |*ppp_class_data| (which can
47 // optionally be NULL if no class data is desired).
48 static bool IsInstanceOf(NPObject* np_object,
49 const PPP_Class_Deprecated* ppp_class,
50 void** ppp_class_data);
52 // Converts the given NPObject to the corresponding ObjectVar.
54 // The given NPObject must be one corresponding to a PluginObject or this
55 // will crash. If the object is a PluginObject but the plugin has gone
56 // away (the object could still be alive because of a reference from JS),
57 // then the return value will be NULL.
58 static PluginObject* FromNPObject(NPObject* object);
60 // Allocates a plugin wrapper object and returns it as an NPObject. This is
61 // used internally only.
62 static NPObject* AllocateObjectWrapper();
64 private:
65 struct NPObjectWrapper;
67 // This object must be created using the CreateObject function of the which
68 // will set up the correct NPObject.
70 // The NPObjectWrapper (an NPObject) should already have the reference
71 // incremented on it, and this class will take ownership of that reference.
72 PluginObject(PepperPluginInstanceImpl* instance,
73 NPObjectWrapper* object_wrapper,
74 const PPP_Class_Deprecated* ppp_class,
75 void* ppp_class_data);
77 PepperPluginInstanceImpl* instance_;
79 // Holds a pointer to the NPObject wrapper backing the var. This class
80 // derives from NPObject and we hold a reference to it, so it must be
81 // refcounted. When the type is not an object, this value will be NULL.
83 // We don't actually own this pointer, it's the NPObject that actually
84 // owns us.
85 NPObjectWrapper* object_wrapper_;
87 const PPP_Class_Deprecated* ppp_class_;
88 void* ppp_class_data_;
90 DISALLOW_COPY_AND_ASSIGN(PluginObject);
93 } // namespace content
95 #endif // CONTENT_RENDERER_PEPPER_PLUGIN_OBJECT_H_