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.
4
5 // From ppb_view.idl modified Wed Jun 11 15:42:26 2014.
6
7 #include "ppapi/c/pp_errors.h"
8 #include "ppapi/c/ppb_view.h"
9 #include "ppapi/shared_impl/tracked_callback.h"
10 #include "ppapi/thunk/enter.h"
11 #include "ppapi/thunk/ppapi_thunk_export.h"
12 #include "ppapi/thunk/ppb_view_api.h"
13
14 namespace ppapi {
15 namespace thunk {
16
17 namespace {
18
IsView(PP_Resource resource)19 PP_Bool IsView(PP_Resource resource) {
20 VLOG(4) << "PPB_View::IsView()";
21 EnterResource<PPB_View_API> enter(resource, false);
22 return PP_FromBool(enter.succeeded());
23 }
24
GetRect(PP_Resource resource,struct PP_Rect * rect)25 PP_Bool GetRect(PP_Resource resource, struct PP_Rect* rect) {
26 VLOG(4) << "PPB_View::GetRect()";
27 EnterResource<PPB_View_API> enter(resource, true);
28 if (enter.failed())
29 return PP_FALSE;
30 return enter.object()->GetRect(rect);
31 }
32
IsFullscreen(PP_Resource resource)33 PP_Bool IsFullscreen(PP_Resource resource) {
34 VLOG(4) << "PPB_View::IsFullscreen()";
35 EnterResource<PPB_View_API> enter(resource, true);
36 if (enter.failed())
37 return PP_FALSE;
38 return enter.object()->IsFullscreen();
39 }
40
IsVisible(PP_Resource resource)41 PP_Bool IsVisible(PP_Resource resource) {
42 VLOG(4) << "PPB_View::IsVisible()";
43 EnterResource<PPB_View_API> enter(resource, true);
44 if (enter.failed())
45 return PP_FALSE;
46 return enter.object()->IsVisible();
47 }
48
IsPageVisible(PP_Resource resource)49 PP_Bool IsPageVisible(PP_Resource resource) {
50 VLOG(4) << "PPB_View::IsPageVisible()";
51 EnterResource<PPB_View_API> enter(resource, true);
52 if (enter.failed())
53 return PP_FALSE;
54 return enter.object()->IsPageVisible();
55 }
56
GetClipRect(PP_Resource resource,struct PP_Rect * clip)57 PP_Bool GetClipRect(PP_Resource resource, struct PP_Rect* clip) {
58 VLOG(4) << "PPB_View::GetClipRect()";
59 EnterResource<PPB_View_API> enter(resource, true);
60 if (enter.failed())
61 return PP_FALSE;
62 return enter.object()->GetClipRect(clip);
63 }
64
GetDeviceScale(PP_Resource resource)65 float GetDeviceScale(PP_Resource resource) {
66 VLOG(4) << "PPB_View::GetDeviceScale()";
67 EnterResource<PPB_View_API> enter(resource, true);
68 if (enter.failed())
69 return 0.0f;
70 return enter.object()->GetDeviceScale();
71 }
72
GetCSSScale(PP_Resource resource)73 float GetCSSScale(PP_Resource resource) {
74 VLOG(4) << "PPB_View::GetCSSScale()";
75 EnterResource<PPB_View_API> enter(resource, true);
76 if (enter.failed())
77 return 0.0f;
78 return enter.object()->GetCSSScale();
79 }
80
GetScrollOffset(PP_Resource resource,struct PP_Point * offset)81 PP_Bool GetScrollOffset(PP_Resource resource, struct PP_Point* offset) {
82 VLOG(4) << "PPB_View::GetScrollOffset()";
83 EnterResource<PPB_View_API> enter(resource, true);
84 if (enter.failed())
85 return PP_FALSE;
86 return enter.object()->GetScrollOffset(offset);
87 }
88
89 const PPB_View_1_0 g_ppb_view_thunk_1_0 = {
90 &IsView,
91 &GetRect,
92 &IsFullscreen,
93 &IsVisible,
94 &IsPageVisible,
95 &GetClipRect
96 };
97
98 const PPB_View_1_1 g_ppb_view_thunk_1_1 = {
99 &IsView,
100 &GetRect,
101 &IsFullscreen,
102 &IsVisible,
103 &IsPageVisible,
104 &GetClipRect,
105 &GetDeviceScale,
106 &GetCSSScale
107 };
108
109 const PPB_View_1_2 g_ppb_view_thunk_1_2 = {
110 &IsView,
111 &GetRect,
112 &IsFullscreen,
113 &IsVisible,
114 &IsPageVisible,
115 &GetClipRect,
116 &GetDeviceScale,
117 &GetCSSScale,
118 &GetScrollOffset
119 };
120
121 } // namespace
122
GetPPB_View_1_0_Thunk()123 PPAPI_THUNK_EXPORT const PPB_View_1_0* GetPPB_View_1_0_Thunk() {
124 return &g_ppb_view_thunk_1_0;
125 }
126
GetPPB_View_1_1_Thunk()127 PPAPI_THUNK_EXPORT const PPB_View_1_1* GetPPB_View_1_1_Thunk() {
128 return &g_ppb_view_thunk_1_1;
129 }
130
GetPPB_View_1_2_Thunk()131 PPAPI_THUNK_EXPORT const PPB_View_1_2* GetPPB_View_1_2_Thunk() {
132 return &g_ppb_view_thunk_1_2;
133 }
134
135 } // namespace thunk
136 } // namespace ppapi
137