Add an exponential backoff to rechecking the app list doodle.
[chromium-blink-merge.git] / ppapi / thunk / ppb_text_input_thunk.cc
blob06c9cd671f3ef725a2df8424cb93685f6dcc98a9
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 #include "base/basictypes.h"
6 #include "ppapi/c/dev/ppb_text_input_dev.h"
7 #include "ppapi/c/ppb_text_input_controller.h"
8 #include "ppapi/shared_impl/var.h"
9 #include "ppapi/thunk/enter.h"
10 #include "ppapi/thunk/ppb_instance_api.h"
11 #include "ppapi/thunk/thunk.h"
13 namespace ppapi {
14 namespace thunk {
16 namespace {
18 #define STATIC_ASSERT_ENUM(a, b) \
19 static_assert(int(a) == int(b), "mismatching enum values: " #a)
21 STATIC_ASSERT_ENUM(PP_TEXTINPUT_TYPE_DEV_NONE, PP_TEXTINPUT_TYPE_NONE);
22 STATIC_ASSERT_ENUM(PP_TEXTINPUT_TYPE_DEV_TEXT, PP_TEXTINPUT_TYPE_TEXT);
23 STATIC_ASSERT_ENUM(PP_TEXTINPUT_TYPE_DEV_PASSWORD, PP_TEXTINPUT_TYPE_PASSWORD);
24 STATIC_ASSERT_ENUM(PP_TEXTINPUT_TYPE_DEV_SEARCH, PP_TEXTINPUT_TYPE_SEARCH);
25 STATIC_ASSERT_ENUM(PP_TEXTINPUT_TYPE_DEV_EMAIL, PP_TEXTINPUT_TYPE_EMAIL);
26 STATIC_ASSERT_ENUM(PP_TEXTINPUT_TYPE_DEV_NUMBER, PP_TEXTINPUT_TYPE_NUMBER);
27 STATIC_ASSERT_ENUM(PP_TEXTINPUT_TYPE_DEV_TELEPHONE,
28 PP_TEXTINPUT_TYPE_TELEPHONE);
29 STATIC_ASSERT_ENUM(PP_TEXTINPUT_TYPE_DEV_URL, PP_TEXTINPUT_TYPE_URL);
31 void SetTextInputType(PP_Instance instance, PP_TextInput_Type type) {
32 EnterInstance enter(instance);
33 if (enter.succeeded())
34 enter.functions()->SetTextInputType(instance, type);
37 void SetTextInputType_0_2(PP_Instance instance, PP_TextInput_Type_Dev type) {
38 EnterInstance enter(instance);
39 if (enter.succeeded())
40 enter.functions()->SetTextInputType(instance,
41 static_cast<PP_TextInput_Type>(type));
44 void UpdateCaretPosition_0_2(PP_Instance instance,
45 const PP_Rect* caret,
46 const PP_Rect* bounding_box) {
47 EnterInstance enter(instance);
48 if (enter.succeeded() && caret && bounding_box)
49 enter.functions()->UpdateCaretPosition(instance, *caret, *bounding_box);
52 void UpdateCaretPosition(PP_Instance instance,
53 const PP_Rect* caret) {
54 EnterInstance enter(instance);
55 if (enter.succeeded() && caret)
56 enter.functions()->UpdateCaretPosition(instance, *caret, PP_Rect());
59 void CancelCompositionText(PP_Instance instance) {
60 EnterInstance enter(instance);
61 if (enter.succeeded())
62 enter.functions()->CancelCompositionText(instance);
65 void UpdateSurroundingText_0_2(PP_Instance instance, const char* text,
66 uint32_t caret, uint32_t anchor) {
67 EnterInstance enter(instance);
68 if (enter.succeeded())
69 enter.functions()->UpdateSurroundingText(instance, text, caret, anchor);
72 void UpdateSurroundingText_1_0(PP_Instance instance, PP_Var text,
73 uint32_t caret, uint32_t anchor) {
74 EnterInstance enter(instance);
75 StringVar* var = StringVar::FromPPVar(text);
76 if (enter.succeeded() && var)
77 enter.functions()->UpdateSurroundingText(instance,
78 var->value().c_str(),
79 caret,
80 anchor);
83 void SelectionChanged(PP_Instance instance) {
84 EnterInstance enter(instance);
85 if (enter.succeeded())
86 enter.functions()->SelectionChanged(instance);
89 const PPB_TextInput_Dev_0_1 g_ppb_textinput_0_1_thunk = {
90 &SetTextInputType_0_2,
91 &UpdateCaretPosition_0_2,
92 &CancelCompositionText,
95 const PPB_TextInput_Dev_0_2 g_ppb_textinput_0_2_thunk = {
96 &SetTextInputType_0_2,
97 &UpdateCaretPosition_0_2,
98 &CancelCompositionText,
99 &UpdateSurroundingText_0_2,
100 &SelectionChanged,
103 const PPB_TextInputController_1_0 g_ppb_textinputcontroller_1_0_thunk = {
104 &SetTextInputType,
105 &UpdateCaretPosition,
106 &CancelCompositionText,
107 &UpdateSurroundingText_1_0,
110 } // namespace
112 const PPB_TextInput_Dev_0_1* GetPPB_TextInput_Dev_0_1_Thunk() {
113 return &g_ppb_textinput_0_1_thunk;
116 const PPB_TextInput_Dev_0_2* GetPPB_TextInput_Dev_0_2_Thunk() {
117 return &g_ppb_textinput_0_2_thunk;
120 const PPB_TextInputController_1_0* GetPPB_TextInputController_1_0_Thunk() {
121 return &g_ppb_textinputcontroller_1_0_thunk;
124 } // namespace thunk
125 } // namespace ppapi