summaryrefslogtreecommitdiffstats
path: root/ppapi/thunk/ppb_instance_thunk.cc
blob: a05f030dee21a4320a3bef7aa5486b6834f5a5ef (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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// Copyright (c) 2011 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.

#include "ppapi/thunk/thunk.h"
#include "ppapi/thunk/enter.h"
#include "ppapi/thunk/ppb_instance_api.h"
#include "ppapi/thunk/resource_creation_api.h"

namespace ppapi {
namespace thunk {

namespace {

PP_Var GetWindowObject(PP_Instance instance) {
  EnterFunction<PPB_Instance_FunctionAPI> enter(instance, true);
  if (enter.failed())
    return PP_MakeUndefined();
  return enter.functions()->GetWindowObject(instance);
}

PP_Var GetOwnerElementObject(PP_Instance instance) {
  EnterFunction<PPB_Instance_FunctionAPI> enter(instance, true);
  if (enter.failed())
    return PP_MakeUndefined();
  return enter.functions()->GetOwnerElementObject(instance);
}

PP_Bool BindGraphics(PP_Instance instance, PP_Resource graphics_id) {
  EnterFunction<PPB_Instance_FunctionAPI> enter(instance, true);
  if (enter.failed())
    return PP_FALSE;
  return enter.functions()->BindGraphics(instance, graphics_id);
}

PP_Bool IsFullFrame(PP_Instance instance) {
  EnterFunction<PPB_Instance_FunctionAPI> enter(instance, true);
  if (enter.failed())
    return PP_FALSE;
  return enter.functions()->IsFullFrame(instance);
}

PP_Var ExecuteScript(PP_Instance instance,
                     PP_Var script,
                     PP_Var* exception) {
  EnterFunction<PPB_Instance_FunctionAPI> enter(instance, true);
  if (enter.failed())
    return PP_MakeUndefined();
  return enter.functions()->ExecuteScript(instance, script, exception);
}

const PPB_Instance_1_0 g_ppb_instance_1_0_thunk = {
  &BindGraphics,
  &IsFullFrame
};

const PPB_Instance_Private g_ppb_instance_private_thunk = {
  &GetWindowObject,
  &GetOwnerElementObject,
  &ExecuteScript
};

}  // namespace

const PPB_Instance_1_0* GetPPB_Instance_1_0_Thunk() {
  return &g_ppb_instance_1_0_thunk;
}
const PPB_Instance_Private* GetPPB_Instance_Private_Thunk() {
  return &g_ppb_instance_private_thunk;
}

}  // namespace thunk
}  // namespace ppapi