seccomp-bpf: Remove legacy SandboxBPFPolicy class
[chromium-blink-merge.git] / chrome / browser / accessibility / accessibility_events.cc
blob394fa60b1167a1fe348a96c13ddecb929d570dcc
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 "chrome/browser/accessibility/accessibility_events.h"
7 #include "base/values.h"
8 #include "chrome/browser/accessibility/accessibility_extension_api.h"
9 #include "chrome/browser/accessibility/accessibility_extension_api_constants.h"
10 #include "chrome/browser/chrome_notification_types.h"
11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/profiles/profile_manager.h"
13 #include "content/public/browser/notification_service.h"
14 #include "content/public/browser/notification_types.h"
16 namespace keys = extension_accessibility_api_constants;
18 void SendControlAccessibilityNotification(
19 ui::AXEvent event,
20 AccessibilityControlInfo* info) {
21 Profile* profile = info->profile();
22 if (profile->ShouldSendAccessibilityEvents()) {
23 ExtensionAccessibilityEventRouter::GetInstance()->HandleControlEvent(
24 event,
25 info);
29 void SendMenuAccessibilityNotification(
30 ui::AXEvent event,
31 AccessibilityMenuInfo* info) {
32 Profile* profile = info->profile();
33 if (profile->ShouldSendAccessibilityEvents()) {
34 ExtensionAccessibilityEventRouter::GetInstance()->HandleMenuEvent(
35 event,
36 info);
40 void SendWindowAccessibilityNotification(
41 ui::AXEvent event,
42 AccessibilityWindowInfo* info) {
43 Profile* profile = info->profile();
44 if (profile->ShouldSendAccessibilityEvents()) {
45 ExtensionAccessibilityEventRouter::GetInstance()->HandleWindowEvent(
46 event,
47 info);
51 AccessibilityControlInfo::AccessibilityControlInfo(
52 Profile* profile, const std::string& name)
53 : AccessibilityEventInfo(profile),
54 name_(name) {
57 AccessibilityControlInfo::~AccessibilityControlInfo() {
60 void AccessibilityControlInfo::SerializeToDict(
61 base::DictionaryValue *dict) const {
62 dict->SetString(keys::kNameKey, name_);
63 dict->SetString(keys::kTypeKey, type());
64 if (!context_.empty())
65 dict->SetString(keys::kContextKey, context_);
66 if (!bounds_.IsEmpty()) {
67 base::DictionaryValue* bounds_value = new base::DictionaryValue();
68 bounds_value->SetInteger(keys::kLeft, bounds_.x());
69 bounds_value->SetInteger(keys::kTop, bounds_.y());
70 bounds_value->SetInteger(keys::kWidth, bounds_.width());
71 bounds_value->SetInteger(keys::kHeight, bounds_.height());
72 dict->Set(keys::kBoundsKey, bounds_value);
76 AccessibilityWindowInfo::AccessibilityWindowInfo(Profile* profile,
77 const std::string& window_name)
78 : AccessibilityControlInfo(profile, window_name) {
81 const char* AccessibilityWindowInfo::type() const {
82 return keys::kTypeWindow;
85 AccessibilityButtonInfo::AccessibilityButtonInfo(Profile* profile,
86 const std::string& button_name,
87 const std::string& context)
88 : AccessibilityControlInfo(profile, button_name) {
89 set_context(context);
92 const char* AccessibilityButtonInfo::type() const {
93 return keys::kTypeButton;
96 AccessibilityStaticTextInfo::AccessibilityStaticTextInfo(Profile* profile,
97 const std::string& text,
98 const std::string& context)
99 : AccessibilityControlInfo(profile, text) {
100 set_context(context);
103 const char* AccessibilityStaticTextInfo::type() const {
104 return keys::kTypeStaticText;
107 AccessibilityLinkInfo::AccessibilityLinkInfo(Profile* profile,
108 const std::string& link_name,
109 const std::string& context)
110 : AccessibilityControlInfo(profile, link_name) {
111 set_context(context);
114 const char* AccessibilityLinkInfo::type() const {
115 return keys::kTypeLink;
118 AccessibilityRadioButtonInfo::AccessibilityRadioButtonInfo(
119 Profile* profile,
120 const std::string& name,
121 const std::string& context,
122 bool checked,
123 int item_index,
124 int item_count)
125 : AccessibilityControlInfo(profile, name),
126 checked_(checked),
127 item_index_(item_index),
128 item_count_(item_count) {
129 set_context(context);
132 const char* AccessibilityRadioButtonInfo::type() const {
133 return keys::kTypeRadioButton;
136 void AccessibilityRadioButtonInfo::SerializeToDict(
137 base::DictionaryValue *dict) const {
138 AccessibilityControlInfo::SerializeToDict(dict);
139 dict->SetBoolean(keys::kCheckedKey, checked_);
140 dict->SetInteger(keys::kItemIndexKey, item_index_);
141 dict->SetInteger(keys::kItemCountKey, item_count_);
144 AccessibilityCheckboxInfo::AccessibilityCheckboxInfo(Profile* profile,
145 const std::string& name,
146 const std::string& context,
147 bool checked)
148 : AccessibilityControlInfo(profile, name),
149 checked_(checked) {
150 set_context(context);
153 const char* AccessibilityCheckboxInfo::type() const {
154 return keys::kTypeCheckbox;
157 void AccessibilityCheckboxInfo::SerializeToDict(
158 base::DictionaryValue *dict) const {
159 AccessibilityControlInfo::SerializeToDict(dict);
160 dict->SetBoolean(keys::kCheckedKey, checked_);
163 AccessibilityTabInfo::AccessibilityTabInfo(Profile* profile,
164 const std::string& tab_name,
165 const std::string& context,
166 int tab_index,
167 int tab_count)
168 : AccessibilityControlInfo(profile, tab_name),
169 tab_index_(tab_index),
170 tab_count_(tab_count) {
171 set_context(context);
174 const char* AccessibilityTabInfo::type() const {
175 return keys::kTypeTab;
178 void AccessibilityTabInfo::SerializeToDict(base::DictionaryValue *dict) const {
179 AccessibilityControlInfo::SerializeToDict(dict);
180 dict->SetInteger(keys::kItemIndexKey, tab_index_);
181 dict->SetInteger(keys::kItemCountKey, tab_count_);
184 AccessibilityComboBoxInfo::AccessibilityComboBoxInfo(Profile* profile,
185 const std::string& name,
186 const std::string& context,
187 const std::string& value,
188 int item_index,
189 int item_count)
190 : AccessibilityControlInfo(profile, name),
191 value_(value),
192 item_index_(item_index),
193 item_count_(item_count) {
194 set_context(context);
197 const char* AccessibilityComboBoxInfo::type() const {
198 return keys::kTypeComboBox;
201 void AccessibilityComboBoxInfo::SerializeToDict(
202 base::DictionaryValue *dict) const {
203 AccessibilityControlInfo::SerializeToDict(dict);
204 dict->SetString(keys::kValueKey, value_);
205 dict->SetInteger(keys::kItemIndexKey, item_index_);
206 dict->SetInteger(keys::kItemCountKey, item_count_);
209 AccessibilityTextBoxInfo::AccessibilityTextBoxInfo(Profile* profile,
210 const std::string& name,
211 const std::string& context,
212 bool password)
213 : AccessibilityControlInfo(profile, name),
214 password_(password),
215 selection_start_(0),
216 selection_end_(0) {
217 set_context(context);
220 const char* AccessibilityTextBoxInfo::type() const {
221 return keys::kTypeTextBox;
224 void AccessibilityTextBoxInfo::SerializeToDict(
225 base::DictionaryValue *dict) const {
226 AccessibilityControlInfo::SerializeToDict(dict);
227 dict->SetString(keys::kValueKey, value_);
228 dict->SetBoolean(keys::kPasswordKey, password_);
229 dict->SetInteger(keys::kSelectionStartKey, selection_start_);
230 dict->SetInteger(keys::kSelectionEndKey, selection_end_);
233 AccessibilityListBoxInfo::AccessibilityListBoxInfo(Profile* profile,
234 const std::string& name,
235 const std::string& context,
236 const std::string& value,
237 int item_index,
238 int item_count)
239 : AccessibilityControlInfo(profile, name),
240 value_(value),
241 item_index_(item_index),
242 item_count_(item_count) {
243 set_context(context);
246 const char* AccessibilityListBoxInfo::type() const {
247 return keys::kTypeListBox;
250 void AccessibilityListBoxInfo::SerializeToDict(
251 base::DictionaryValue *dict) const {
252 AccessibilityControlInfo::SerializeToDict(dict);
253 dict->SetString(keys::kValueKey, value_);
254 dict->SetInteger(keys::kItemIndexKey, item_index_);
255 dict->SetInteger(keys::kItemCountKey, item_count_);
258 AccessibilityMenuInfo::AccessibilityMenuInfo(Profile* profile,
259 const std::string& menu_name)
260 : AccessibilityControlInfo(profile, menu_name) {
263 const char* AccessibilityMenuInfo::type() const {
264 return keys::kTypeMenu;
267 AccessibilityMenuItemInfo::AccessibilityMenuItemInfo(Profile* profile,
268 const std::string& name,
269 const std::string& context,
270 bool has_submenu,
271 int item_index,
272 int item_count)
273 : AccessibilityControlInfo(profile, name),
274 has_submenu_(has_submenu),
275 item_index_(item_index),
276 item_count_(item_count) {
277 set_context(context);
280 const char* AccessibilityMenuItemInfo::type() const {
281 return keys::kTypeMenuItem;
284 void AccessibilityMenuItemInfo::SerializeToDict(
285 base::DictionaryValue *dict) const {
286 AccessibilityControlInfo::SerializeToDict(dict);
287 dict->SetBoolean(keys::kHasSubmenuKey, has_submenu_);
288 dict->SetInteger(keys::kItemIndexKey, item_index_);
289 dict->SetInteger(keys::kItemCountKey, item_count_);
292 AccessibilityTreeInfo::AccessibilityTreeInfo(Profile* profile,
293 const std::string& menu_name)
294 : AccessibilityControlInfo(profile, menu_name) {
297 const char* AccessibilityTreeInfo::type() const {
298 return keys::kTypeTree;
301 AccessibilityTreeItemInfo::AccessibilityTreeItemInfo(Profile* profile,
302 const std::string& name,
303 const std::string& context,
304 int item_depth,
305 int item_index,
306 int item_count,
307 int children_count,
308 bool is_expanded)
309 : AccessibilityControlInfo(profile, name),
310 item_depth_(item_depth),
311 item_index_(item_index),
312 item_count_(item_count),
313 children_count_(children_count),
314 is_expanded_(is_expanded) {
315 set_context(context);
318 const char* AccessibilityTreeItemInfo::type() const {
319 return keys::kTypeTreeItem;
322 void AccessibilityTreeItemInfo::SerializeToDict(
323 base::DictionaryValue *dict) const {
324 AccessibilityControlInfo::SerializeToDict(dict);
325 dict->SetInteger(keys::kItemDepthKey, item_depth_);
326 dict->SetInteger(keys::kItemIndexKey, item_index_);
327 dict->SetInteger(keys::kItemCountKey, item_count_);
328 dict->SetInteger(keys::kChildrenCountKey, children_count_);
329 dict->SetBoolean(keys::kItemExpandedKey, is_expanded_);
332 AccessibilitySliderInfo::AccessibilitySliderInfo(Profile* profile,
333 const std::string& name,
334 const std::string& context,
335 const std::string& value)
336 : AccessibilityControlInfo(profile, name),
337 value_(value) {
338 set_context(context);
341 const char* AccessibilitySliderInfo::type() const {
342 return keys::kTypeSlider;
345 void AccessibilitySliderInfo::SerializeToDict(
346 base::DictionaryValue *dict) const {
347 AccessibilityControlInfo::SerializeToDict(dict);
348 dict->SetString(keys::kStringValueKey, value_);
351 AccessibilityAlertInfo::AccessibilityAlertInfo(Profile* profile,
352 const std::string& name)
353 : AccessibilityControlInfo(profile, name) {
356 const char* AccessibilityAlertInfo::type() const {
357 return keys::kTypeAlert;