FireBreath  1.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Pages
NpapiPlugin.h
1 /**********************************************************\
2 Original Author: Richard Bateman (taxilian)
3 
4 Created: Oct 19, 2009
5 License: Dual license model; choose one of two:
6  New BSD License
7  http://www.opensource.org/licenses/bsd-license.php
8  - or -
9  GNU Lesser General Public License, version 2.1
10  http://www.gnu.org/licenses/lgpl-2.1.html
11 
12 Copyright 2009 Richard Bateman, Firebreath development team
13 \**********************************************************/
14 
15 #pragma once
16 #ifndef H_FB_NPAPI_NPAPIPLUGIN
17 #define H_FB_NPAPI_NPAPIPLUGIN
18 
19 #include "NpapiTypes.h"
20 #include "NpapiBrowserHost.h"
21 #include "NPJavascriptObject.h"
22 #include "BrowserPlugin.h"
23 
24 namespace FB {
25  FB_FORWARD_PTR(BrowserStream);
26 
27  namespace Npapi {
28 
29  struct PluginCreateError : std::runtime_error
30  {
31  PluginCreateError(const std::string& error)
32  : std::runtime_error(error)
33  { }
34  };
35 
36  FB_FORWARD_PTR(NpapiPlugin);
37 
38  class NpapiPlugin : public FB::BrowserPlugin
39  {
40  public:
41  NpapiPlugin(const NpapiBrowserHostPtr& host, const std::string& mimetype);
42  virtual ~NpapiPlugin(void);
43 
44  virtual void init(NPMIMEType pluginType, int16_t argc, char* argn[], char *argv[]);
45  virtual void shutdown();
46 
47  virtual bool setReady();
48 
49  protected:
50  NPJavascriptObject *m_obj;
51  NpapiBrowserHostPtr m_npHost;
52  bool m_retainReturnedNPObject;
53  bool m_isReady;
54  std::string m_mimetype;
55  std::string m_pluginName;
56  std::string m_pluginDesc;
57 
65  NPObject *getScriptableObject();
66  static void signalStreamOpened(FB::BrowserStream* stream);
67 
68  public:
69  // These calls are proxied from the NpapiPluginModule to this object, and are
70  // the NPP_ functions given to the browser; essentially, the entrypoints for the
71  // plugin instance
72  virtual NPError SetWindow(NPWindow* window);
73  virtual NPError NewStream(NPMIMEType type, NPStream* stream, NPBool seekable, uint16_t* stype);
74  virtual NPError DestroyStream(NPStream* stream, NPReason reason);
75  virtual int32_t WriteReady(NPStream* stream);
76  virtual int32_t Write(NPStream* stream, int32_t offset, int32_t len, void* buffer);
77  virtual void StreamAsFile(NPStream* stream, const char* fname);
78  virtual void Print(NPPrint* platformPrint);
79  virtual int16_t HandleEvent(void* event);
80  virtual void URLNotify(const char* url, NPReason reason, void* notifyData);
81  virtual NPError GetValue(NPPVariable variable, void *);
82  virtual NPError SetValue(NPNVariable variable, void *);
83  };
84 
85 }; }; // FB::Npapi
86 
87 #endif
88 
This is the abstract base class (interface class) for a browser stream.
Definition: BrowserStream.h:41
Browser-specific plugin base class.
Definition: BrowserPlugin.h:38