#ifndef CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_BINDINGS_H__
#define CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_BINDINGS_H__
#include "base/memory/scoped_vector.h"
#include "base/memory/weak_ptr.h"
#include "ppapi/shared_impl/resource.h"
#include "third_party/npapi/bindings/npruntime.h"
namespace content {
class BrowserPlugin;
class BrowserPluginMethodBinding;
class BrowserPluginPropertyBinding;
class BrowserPluginBindings {
public:
struct BrowserPluginNPObject : public NPObject {
BrowserPluginNPObject();
~BrowserPluginNPObject();
base::WeakPtr<BrowserPluginBindings> message_channel;
};
explicit BrowserPluginBindings(BrowserPlugin* instance);
~BrowserPluginBindings();
NPObject* np_object() const { return np_object_; }
BrowserPlugin* instance() const { return instance_; }
bool HasMethod(NPIdentifier name) const;
bool InvokeMethod(NPIdentifier name,
const NPVariant* args,
uint32 arg_count,
NPVariant* result);
bool HasProperty(NPIdentifier name) const;
bool SetProperty(NPObject* np_obj,
NPIdentifier name,
const NPVariant* variant);
bool GetProperty(NPIdentifier name, NPVariant* result);
bool RemoveProperty(NPObject *np_obj, NPIdentifier name);
private:
BrowserPlugin* instance_;
BrowserPluginNPObject* np_object_;
typedef ScopedVector<BrowserPluginMethodBinding> BindingList;
BindingList method_bindings_;
typedef ScopedVector<BrowserPluginPropertyBinding> PropertyBindingList;
PropertyBindingList property_bindings_;
base::WeakPtrFactory<BrowserPluginBindings> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(BrowserPluginBindings);
};
}
#endif