summaryrefslogtreecommitdiffstats
path: root/webkit/glue/plugins/pepper_var.h
blob: 7b95b338dc70585cd89cb5f21f5bccd9ebbc59b9 (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
// Copyright (c) 2010 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 WEBKIT_GLUE_PLUGINS_PEPPER_VAR_H_
#define WEBKIT_GLUE_PLUGINS_PEPPER_VAR_H_

#include <string>

typedef struct _pp_Var PP_Var;
typedef struct _ppb_Var PPB_Var;
typedef struct NPObject NPObject;
typedef struct _NPVariant NPVariant;
typedef void* NPIdentifier;

namespace pepper {

class String;

// There's no class implementing Var since it could represent a number of
// objects. Instead, we just expose a getter for the interface implemented in
// the .cc file here.
const PPB_Var* GetVarInterface();

// Returns a PP_Var of type object that wraps the given NPObject.  Calling this
// function multiple times given the same NPObject results in the same PP_Var.
PP_Var NPObjectToPPVar(NPObject* object);

// Returns the NPObject corresponding to the PP_Var.  This pointer has not been
// retained, so you should not call WebBindings::releaseObject unless you first
// call WebBindings::retainObject.  Returns NULL if the PP_Var is not an object
// type.
NPObject* GetNPObject(PP_Var var);

// Returns a PP_Var of type string that contains a copy of the given string.
// The input data must be valid UTF-8 encoded text. The return value will
// have a reference count of 1.
PP_Var StringToPPVar(const std::string& str);

// Returns the String corresponding to the PP_Var.  This pointer has not been
// AddRef'd, so you should not call Release!  Returns NULL if the PP_Var is not
// a string type.
String* GetString(PP_Var var);

}  // namespace pepper

#endif  // WEBKIT_GLUE_PLUGINS_PEPPER_VAR_H_