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