Revert 264226 "Reduce dependency of TiclInvalidationService on P..."
[chromium-blink-merge.git] / remoting / host / plugin / host_plugin_utils.h
bloba7348bb9744c9053e665b94f455c3d7ddce3bf7f
1 // Copyright (c) 2012 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 REMOTING_HOST_PLUGIN_HOST_PLUGIN_UTILS_H_
6 #define REMOTING_HOST_PLUGIN_HOST_PLUGIN_UTILS_H_
8 #include <string>
10 #include "third_party/npapi/bindings/npapi.h"
11 #include "third_party/npapi/bindings/npfunctions.h"
12 #include "third_party/npapi/bindings/npruntime.h"
14 namespace remoting {
16 // Global netscape functions initialized in NP_Initialize.
17 extern NPNetscapeFuncs* g_npnetscape_funcs;
19 // Convert an NPIdentifier into a std::string.
20 std::string StringFromNPIdentifier(NPIdentifier identifier);
22 // Convert an NPVariant into a std::string.
23 std::string StringFromNPVariant(const NPVariant& variant);
25 // Convert a std::string into an NPVariant.
26 // Caller is responsible for making sure that NPN_ReleaseVariantValue is
27 // called on returned value.
28 NPVariant NPVariantFromString(const std::string& val);
30 // Convert an NPVariant into an NSPObject.
31 NPObject* ObjectFromNPVariant(const NPVariant& variant);
33 // Scoped reference pointer for NPObjects. All objects using this class
34 // must be owned by g_npnetscape_funcs.
35 class ScopedRefNPObject {
36 public:
37 ScopedRefNPObject();
38 explicit ScopedRefNPObject(NPObject* object);
39 explicit ScopedRefNPObject(const ScopedRefNPObject& object);
40 ~ScopedRefNPObject();
42 // Release the held reference and replace it with |object|, incrementing
43 // its reference count.
44 ScopedRefNPObject& operator=(NPObject* object);
45 ScopedRefNPObject& operator=(const ScopedRefNPObject& object);
47 NPObject* get() const { return object_; }
49 private:
50 NPObject* object_;
53 } // namespace remoting
55 #endif // REMOTING_HOST_PLUGIN_HOST_PLUGIN_UTILS_H_