summaryrefslogtreecommitdiff
path: root/chromium/components/arc/common/accessibility_helper.mojom
blob: 7cc1327546c9277ede62f6f61f376b726effa9d1 (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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
// Copyright 2017 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.

// Next MinVersion: 9

module arc.mojom;

import "screen_rect.mojom";

// For future maintainers, each of the below enums were hand picked
// from their equivalents in the Android source. Keep them in the
// order given below and add as needed. The initial order matches the
// order they appear in source files.
//
// If not explicitly called out, the structs and enums below come from:
// https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html

// AccessibilityEventType lists the possible accessibility events on Android.
// https://developer.android.com/reference/android/view/accessibility/AccessibilityEvent.html
[Extensible]
enum AccessibilityEventType {
  VIEW_FOCUSED,
  VIEW_CLICKED,
  VIEW_LONG_CLICKED,
  VIEW_SELECTED,
  VIEW_TEXT_CHANGED,
  WINDOW_STATE_CHANGED,
  NOTIFICATION_STATE_CHANGED,
  VIEW_HOVER_ENTER,
  VIEW_HOVER_EXIT,
  TOUCH_EXPLORATION_GESTURE_START,
  TOUCH_EXPLORATION_GESTURE_END,
  WINDOW_CONTENT_CHANGED,
  VIEW_SCROLLED,
  VIEW_TEXT_SELECTION_CHANGED,
  ANNOUNCEMENT,
  VIEW_ACCESSIBILITY_FOCUSED,
  VIEW_ACCESSIBILITY_FOCUS_CLEARED,
  VIEW_TEXT_TRAVERSED_AT_MOVEMENT_GRANULARITY,
  GESTURE_DETECTION_START,
  GESTURE_DETECTION_END,
  TOUCH_INTERACTION_START,
  TOUCH_INTERACTION_END,
  WINDOWS_CHANGED,
  VIEW_CONTEXT_CLICKED,
  ASSIST_READING_CONTEXT,
};

// Possible actions that can be performed on an AccessibilityNodeInfo.
[Extensible]
enum AccessibilityActionType {
  FOCUS,
  CLEAR_FOCUS,
  SELECT,
  CLEAR_SELECTION,
  CLICK,
  LONG_CLICK,
  ACCESSIBILITY_FOCUS,
  CLEAR_ACCESSIBILITY_FOCUS,
  NEXT_AT_MOVEMENT_GRANULARITY,  // unused
  PREVIOUS_AT_MOVEMENT_GRANULARITY,  // unused
  NEXT_HTML_ELEMENT,  // unused
  PREVIOUS_HTML_ELEMENT,  // unused
  SCROLL_FORWARD,
  SCROLL_BACKWARD,
  COPY,
  PASTE,
  CUT,
  SET_SELECTION,
  EXPAND,
  COLLAPSE,
  DISMISS,
  SET_TEXT,
  CONTEXT_CLICK,
  SCROLL_DOWN,
  SCROLL_LEFT,
  SCROLL_RIGHT,
  SCROLL_TO_POSITION,
  SCROLL_UP,
  SET_PROGRESS,
  SHOW_ON_SCREEN,
  CUSTOM_ACTION  // Not a standard action.
};

// Possible boolean properties set on an AccessibilityNodeInfo.
// The enum values appear in the same order as they do within
// AccessibilityNodeInfo.java.
[Extensible]
enum AccessibilityBooleanProperty {
  CHECKABLE,
  CHECKED,
  FOCUSABLE,
  FOCUSED,
  SELECTED,
  CLICKABLE,
  LONG_CLICKABLE,
  ENABLED,
  PASSWORD,
  SCROLLABLE,
  ACCESSIBILITY_FOCUSED,
  VISIBLE_TO_USER,
  EDITABLE,
  OPENS_POPUP,
  DISMISSABLE,
  MULTI_LINE,
  CONTENT_INVALID,
  CONTEXT_CLICKABLE,
  IMPORTANCE
};

// These fields are taken from string instance members of
// AccessibilityNodeInfo.
[Extensible]
enum AccessibilityStringProperty {
  PACKAGE_NAME,
  CLASS_NAME,
  TEXT,
  CONTENT_DESCRIPTION,
  VIEW_ID_RESOURCE_NAME,
  CHROME_ROLE,  // Chrome only
  ROLE_DESCRIPTION  // Chrome only
};

// These fields are taken from int instance members of
// AccessibilityNodeInfo.
[Extensible]
enum AccessibilityIntProperty {
  LABEL_FOR,
  LABELED_BY,
  TRAVERSAL_BEFORE,
  TRAVERSAL_AFTER,
  MAX_TEXT_LENGTH,
  TEXT_SELECTION_START,
  TEXT_SELECTION_END,
  INPUT_TYPE,
  LIVE_REGION
};

// These fields are taken from List<int> instance members of
// AccessibilityNodeInfo.
[Extensible]
enum AccessibilityIntListProperty {
  CHILD_NODE_IDS,
  CUSTOM_ACTION_IDS
};

// These fields are taken from List<String> instance members of
// AccessibilityNodeInfo.
[Extensible]
enum AccessibilityStringListProperty {
  CUSTOM_ACTION_DESCRIPTIONS
};

// This type is a subset of spans available under android.text.style.
[Extensible]
enum SpanType {
  URL,
  CLICKABLE
};

// Groups data about a Spannable.
struct SpanEntry {
  int32 start;
  int32 end;
  SpanType span_type;
};

// These fields are taken from AccessibilityNodeInfo.CollectionItemInfo.
[Extensible]
enum AccessibilitySelectionMode {
  NONE,
  SINGLE,
  MULTIPLE
};

// These fields are taken from AccessibilityNodeInfo.CollectionInfo.
struct AccessibilityCollectionInfoData {
  int32 row_count;
  int32 column_count;
  bool is_hierarchical;
  AccessibilitySelectionMode selection_mode;
};

// These fields are taken from AccessibilityNodeInfo.CollectionItemInfo.
struct AccessibilityCollectionItemInfoData {
  int32 row_index;
  int32 column_index;
  int32 row_span;
  int32 column_span;
  bool is_heading;
  bool is_selected;
};

// These fields are taken from AccessibilityNodeInfo.RangeInfo.
[Extensible]
enum AccessibilityRangeType {
  INT,
  FLOAT,
  PERCENT
};

// These fields are taken from AccessibilityNodeInfo.RangeInfo.
struct AccessibilityRangeInfoData {
  AccessibilityRangeType range_type;
  float min;
  float max;
  float current;
};

// AccessibilityNodeInfoData is a struct to contain info of
// AccessibilityNodeInfo in Android.
struct AccessibilityNodeInfoData {
  ScreenRect bounds_in_screen;
  [MinVersion=1]int32 id;
  [MinVersion=1]map<AccessibilityBooleanProperty, bool>? boolean_properties;
  [MinVersion=1]map<AccessibilityStringProperty, string>? string_properties;
  [MinVersion=1]map<AccessibilityIntProperty, int32>? int_properties;
  [MinVersion=1]
      map<AccessibilityIntListProperty, array<int32>>? int_list_properties;
  [MinVersion=3]map<AccessibilityStringListProperty, array<string>>?
      string_list_properties;
  [MinVersion=5]map<AccessibilityStringProperty, array<SpanEntry>>?
      spannable_string_properties;
  [MinVersion=5]AccessibilityCollectionInfoData? collection_info;
  [MinVersion=5]AccessibilityCollectionItemInfoData? collection_item_info;
  [MinVersion=5]AccessibilityRangeInfoData? range_info;
};

// Filters the event type (and implicitly the data) sent by the ARC
// accessibility service.
[Extensible]
enum AccessibilityFilterType {
  // No events will be sent.
  OFF,

  // Only send focus events along with the source focus node.
  FOCUS,

  // Send a complete tree from the event source's root for every event.
  ALL,

  // Send complete subtrees for root nodes with whitelisted package names.
  [MinVersion=2]WHITELISTED_PACKAGE_NAME
};

// AccessibilityEventData is a struct to contain info of
// AccessibilityEvent in Android.
// https://developer.android.com/reference/android/view/accessibility/AccessibilityEvent.html
struct AccessibilityEventData {
  AccessibilityEventType event_type;
  int32 source_id;
  array<AccessibilityNodeInfoData> node_data;

  // notification_key is set only for an event on an Android notification.
  [MinVersion=6]string? notification_key;

  // window_id where this event is dispatched for. While this window_id matches
  // with AccessibilityNodeInfo.getWindowId now, do not expect that it always
  // matches with it.
  [MinVersion=6]int32 window_id;

  // Task associated with this event (usually the front task when this event
  // gets dispatched).
  [MinVersion=8]int32 task_id;
};

// AccessibilityActionData is a struct to contain info of AccessibilityAction in
// Android.
// https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.AccessibilityAction.html
struct AccessibilityActionData {
  int32 node_id;

  AccessibilityActionType action_type;

  // custom_action_id must be set if action_type is CUSTOM_ACTION.
  int32 custom_action_id;

  // window_id where the action is performed on.
  [MinVersion=6]int32 window_id;
};

// Next method ID: 2
interface AccessibilityHelperHost {
  OnAccessibilityEventDeprecated@0(AccessibilityEventType event_type,
                                   AccessibilityNodeInfoData? event_source);

  // OnAccessibilityEvent is called when a converted Android accessibility event
  // is sent from Android.
  OnAccessibilityEvent@1(AccessibilityEventData event_data);
};

// Next method ID: 7
interface AccessibilityHelperInstance {
  Init@0(AccessibilityHelperHost host);

  PerformActionDeprecated@1(int32 id, AccessibilityActionType action);

  // Set a filter on the event types received.
  SetFilter@2(AccessibilityFilterType filter_type);

  [MinVersion=3]PerformActionDeprecated2@3(AccessibilityActionData action_data);

  // Perform an action on a node requested by a Chrome client.
  [MinVersion=4]PerformAction@4(AccessibilityActionData action_data)
      => (bool result);

  // Sets the package to use ChromeVox (true) or TalkBack (false). Returns true
  // if the request was processed.
  [MinVersion=7]SetNativeChromeVoxArcSupportDeprecated@5(
      string package_name, bool enabled) => (bool processed);

  // Sets the focused window's package to use ChromeVox (true) or TalkBack
  // (false).
  [MinVersion=8]SetNativeChromeVoxArcSupportForFocusedWindow@6(
      bool enabled) => (bool processed);
};