OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // TODO: Need mechanism to cleanup the static instance | 5 // TODO: Need mechanism to cleanup the static instance |
6 | 6 |
7 #ifndef WEBKIT_PLUGINS_NPAPI_PLUGIN_HOST_H_ | 7 #ifndef WEBKIT_PLUGINS_NPAPI_PLUGIN_HOST_H_ |
8 #define WEBKIT_PLUGINS_NPAPI_PLUGIN_HOST_H_ | 8 #define WEBKIT_PLUGINS_NPAPI_PLUGIN_HOST_H_ |
9 | 9 |
10 #include <string> | 10 #include <string> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "third_party/npapi/bindings/npapi.h" | 14 #include "third_party/npapi/bindings/npapi.h" |
15 #include "third_party/npapi/bindings/nphostapi.h" | 15 #include "third_party/npapi/bindings/nphostapi.h" |
| 16 #include "webkit/plugins/webkit_plugins_export.h" |
16 | 17 |
17 namespace webkit { | 18 namespace webkit { |
18 namespace npapi { | 19 namespace npapi { |
19 | 20 |
20 // The Plugin Host implements the NPN_xxx functions for NPAPI plugins. | 21 // The Plugin Host implements the NPN_xxx functions for NPAPI plugins. |
21 // These are the functions exposed from the Plugin Host for use | 22 // These are the functions exposed from the Plugin Host for use |
22 // by the Plugin. | 23 // by the Plugin. |
23 // | 24 // |
24 // The PluginHost is managed as a singleton. This isn't strictly | 25 // The PluginHost is managed as a singleton. This isn't strictly |
25 // necessary, but since the callback functions are all global C | 26 // necessary, but since the callback functions are all global C |
26 // functions, there is really no point in having per-instance PluginHosts. | 27 // functions, there is really no point in having per-instance PluginHosts. |
27 class PluginHost : public base::RefCounted<PluginHost> { | 28 class PluginHost : public base::RefCounted<PluginHost> { |
28 public: | 29 public: |
29 // Access the single PluginHost instance. Callers | 30 // Access the single PluginHost instance. Callers |
30 // must call deref() when finished with the object. | 31 // must call deref() when finished with the object. |
31 static PluginHost* Singleton(); | 32 WEBKIT_PLUGINS_EXPORT static PluginHost* Singleton(); |
32 | 33 |
33 // The table of functions provided to the plugin. | 34 // The table of functions provided to the plugin. |
34 NPNetscapeFuncs* host_functions() { return &host_funcs_; } | 35 NPNetscapeFuncs* host_functions() { return &host_funcs_; } |
35 | 36 |
36 // Helper function for parsing post headers, and applying attributes | 37 // Helper function for parsing post headers, and applying attributes |
37 // to the stream. NPAPI post data include headers + data combined. | 38 // to the stream. NPAPI post data include headers + data combined. |
38 // This function parses it out and adds it to the stream in a WebKit | 39 // This function parses it out and adds it to the stream in a WebKit |
39 // style. | 40 // style. |
40 static bool SetPostData(const char *buf, | 41 static bool SetPostData(const char *buf, |
41 uint32 length, | 42 uint32 length, |
42 std::vector<std::string>* names, | 43 std::vector<std::string>* names, |
43 std::vector<std::string>* values, | 44 std::vector<std::string>* values, |
44 std::vector<char>* body); | 45 std::vector<char>* body); |
45 | 46 |
46 void PatchNPNetscapeFuncs(NPNetscapeFuncs* overrides); | 47 WEBKIT_PLUGINS_EXPORT void PatchNPNetscapeFuncs(NPNetscapeFuncs* overrides); |
47 | 48 |
48 private: | 49 private: |
49 friend class base::RefCounted<PluginHost>; | 50 friend class base::RefCounted<PluginHost>; |
50 | 51 |
51 virtual ~PluginHost(); | 52 virtual ~PluginHost(); |
52 | 53 |
53 PluginHost(); | 54 PluginHost(); |
54 void InitializeHostFuncs(); | 55 void InitializeHostFuncs(); |
55 NPNetscapeFuncs host_funcs_; | 56 NPNetscapeFuncs host_funcs_; |
56 DISALLOW_COPY_AND_ASSIGN(PluginHost); | 57 DISALLOW_COPY_AND_ASSIGN(PluginHost); |
57 }; | 58 }; |
58 | 59 |
59 } // namespace npapi | 60 } // namespace npapi |
60 } // namespace webkit | 61 } // namespace webkit |
61 | 62 |
62 #endif // WEBKIT_PLUGINS_NPAPI_PLUGIN_HOST_H_ | 63 #endif // WEBKIT_PLUGINS_NPAPI_PLUGIN_HOST_H_ |
OLD | NEW |