blob: a7348bb9744c9053e665b94f455c3d7ddce3bf7f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef REMOTING_HOST_PLUGIN_HOST_PLUGIN_UTILS_H_
#define REMOTING_HOST_PLUGIN_HOST_PLUGIN_UTILS_H_
#include <string>
#include "third_party/npapi/bindings/npapi.h"
#include "third_party/npapi/bindings/npfunctions.h"
#include "third_party/npapi/bindings/npruntime.h"
namespace remoting {
// Global netscape functions initialized in NP_Initialize.
extern NPNetscapeFuncs* g_npnetscape_funcs;
// Convert an NPIdentifier into a std::string.
std::string StringFromNPIdentifier(NPIdentifier identifier);
// Convert an NPVariant into a std::string.
std::string StringFromNPVariant(const NPVariant& variant);
// Convert a std::string into an NPVariant.
// Caller is responsible for making sure that NPN_ReleaseVariantValue is
// called on returned value.
NPVariant NPVariantFromString(const std::string& val);
// Convert an NPVariant into an NSPObject.
NPObject* ObjectFromNPVariant(const NPVariant& variant);
// Scoped reference pointer for NPObjects. All objects using this class
// must be owned by g_npnetscape_funcs.
class ScopedRefNPObject {
public:
ScopedRefNPObject();
explicit ScopedRefNPObject(NPObject* object);
explicit ScopedRefNPObject(const ScopedRefNPObject& object);
~ScopedRefNPObject();
// Release the held reference and replace it with |object|, incrementing
// its reference count.
ScopedRefNPObject& operator=(NPObject* object);
ScopedRefNPObject& operator=(const ScopedRefNPObject& object);
NPObject* get() const { return object_; }
private:
NPObject* object_;
};
} // namespace remoting
#endif // REMOTING_HOST_PLUGIN_HOST_PLUGIN_UTILS_H_
|