Separate Simple Backend creation from initialization.
[chromium-blink-merge.git] / ppapi / thunk / ppb_view_thunk.cc
blob04a3931c56e84c059ab36911858376606ed98f2a
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 // From ppb_view.idl modified Thu Mar 28 11:12:59 2013.
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/ppb_instance_api.h"
12 #include "ppapi/thunk/ppb_view_api.h"
13 #include "ppapi/thunk/resource_creation_api.h"
14 #include "ppapi/thunk/thunk.h"
16 namespace ppapi {
17 namespace thunk {
19 namespace {
21 PP_Bool IsView(PP_Resource resource) {
22 VLOG(4) << "PPB_View::IsView()";
23 EnterResource<PPB_View_API> enter(resource, false);
24 return PP_FromBool(enter.succeeded());
27 PP_Bool GetRect(PP_Resource resource, struct PP_Rect* rect) {
28 VLOG(4) << "PPB_View::GetRect()";
29 EnterResource<PPB_View_API> enter(resource, true);
30 if (enter.failed())
31 return PP_FALSE;
32 return enter.object()->GetRect(rect);
35 PP_Bool IsFullscreen(PP_Resource resource) {
36 VLOG(4) << "PPB_View::IsFullscreen()";
37 EnterResource<PPB_View_API> enter(resource, true);
38 if (enter.failed())
39 return PP_FALSE;
40 return enter.object()->IsFullscreen();
43 PP_Bool IsVisible(PP_Resource resource) {
44 VLOG(4) << "PPB_View::IsVisible()";
45 EnterResource<PPB_View_API> enter(resource, true);
46 if (enter.failed())
47 return PP_FALSE;
48 return enter.object()->IsVisible();
51 PP_Bool IsPageVisible(PP_Resource resource) {
52 VLOG(4) << "PPB_View::IsPageVisible()";
53 EnterResource<PPB_View_API> enter(resource, true);
54 if (enter.failed())
55 return PP_FALSE;
56 return enter.object()->IsPageVisible();
59 PP_Bool GetClipRect(PP_Resource resource, struct PP_Rect* clip) {
60 VLOG(4) << "PPB_View::GetClipRect()";
61 EnterResource<PPB_View_API> enter(resource, true);
62 if (enter.failed())
63 return PP_FALSE;
64 return enter.object()->GetClipRect(clip);
67 float GetDeviceScale(PP_Resource resource) {
68 EnterResource<PPB_View_API> enter(resource, true);
69 if (enter.failed())
70 return 0.0f;
71 return enter.object()->GetDeviceScale();
74 float GetCSSScale(PP_Resource resource) {
75 EnterResource<PPB_View_API> enter(resource, true);
76 if (enter.failed())
77 return 0.0f;
78 return enter.object()->GetCSSScale();
81 const PPB_View_1_0 g_ppb_view_thunk_1_0 = {
82 &IsView,
83 &GetRect,
84 &IsFullscreen,
85 &IsVisible,
86 &IsPageVisible,
87 &GetClipRect
90 const PPB_View_1_1 g_ppb_view_thunk_1_1 = {
91 &IsView,
92 &GetRect,
93 &IsFullscreen,
94 &IsVisible,
95 &IsPageVisible,
96 &GetClipRect,
97 &GetDeviceScale,
98 &GetCSSScale
101 } // namespace
103 const PPB_View_1_0* GetPPB_View_1_0_Thunk() {
104 return &g_ppb_view_thunk_1_0;
107 const PPB_View_1_1* GetPPB_View_1_1_Thunk() {
108 return &g_ppb_view_thunk_1_1;
111 } // namespace thunk
112 } // namespace ppapi