Separate Simple Backend creation from initialization.
[chromium-blink-merge.git] / ppapi / thunk / ppb_widget_dev_thunk.cc
blob3a6fab943770eb616874a0fbb9742c17d7ddf943
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 dev/ppb_widget_dev.idl modified Thu Dec 20 13:10:26 2012.
7 #include "ppapi/c/dev/ppb_widget_dev.h"
8 #include "ppapi/c/pp_errors.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_widget_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 IsWidget(PP_Resource resource) {
22 VLOG(4) << "PPB_Widget_Dev::IsWidget()";
23 EnterResource<PPB_Widget_API> enter(resource, false);
24 return PP_FromBool(enter.succeeded());
27 PP_Bool Paint(PP_Resource widget,
28 const struct PP_Rect* rect,
29 PP_Resource image) {
30 VLOG(4) << "PPB_Widget_Dev::Paint()";
31 EnterResource<PPB_Widget_API> enter(widget, false);
32 if (enter.failed())
33 return PP_FALSE;
34 return enter.object()->Paint(rect, image);
37 PP_Bool HandleEvent(PP_Resource widget, PP_Resource input_event) {
38 VLOG(4) << "PPB_Widget_Dev::HandleEvent()";
39 EnterResource<PPB_Widget_API> enter(widget, false);
40 if (enter.failed())
41 return PP_FALSE;
42 return enter.object()->HandleEvent(input_event);
45 PP_Bool GetLocation(PP_Resource widget, struct PP_Rect* location) {
46 VLOG(4) << "PPB_Widget_Dev::GetLocation()";
47 EnterResource<PPB_Widget_API> enter(widget, false);
48 if (enter.failed())
49 return PP_FALSE;
50 return enter.object()->GetLocation(location);
53 void SetLocation(PP_Resource widget, const struct PP_Rect* location) {
54 VLOG(4) << "PPB_Widget_Dev::SetLocation()";
55 EnterResource<PPB_Widget_API> enter(widget, false);
56 if (enter.succeeded())
57 enter.object()->SetLocation(location);
60 void SetScale(PP_Resource widget, float scale) {
61 VLOG(4) << "PPB_Widget_Dev::SetScale()";
62 EnterResource<PPB_Widget_API> enter(widget, false);
63 if (enter.succeeded())
64 enter.object()->SetScale(scale);
67 const PPB_Widget_Dev_0_3 g_ppb_widget_dev_thunk_0_3 = {
68 &IsWidget,
69 &Paint,
70 &HandleEvent,
71 &GetLocation,
72 &SetLocation
75 const PPB_Widget_Dev_0_4 g_ppb_widget_dev_thunk_0_4 = {
76 &IsWidget,
77 &Paint,
78 &HandleEvent,
79 &GetLocation,
80 &SetLocation,
81 &SetScale
84 } // namespace
86 const PPB_Widget_Dev_0_3* GetPPB_Widget_Dev_0_3_Thunk() {
87 return &g_ppb_widget_dev_thunk_0_3;
90 const PPB_Widget_Dev_0_4* GetPPB_Widget_Dev_0_4_Thunk() {
91 return &g_ppb_widget_dev_thunk_0_4;
94 } // namespace thunk
95 } // namespace ppapi