app_shell: Add version number in user agent
[chromium-blink-merge.git] / chrome / browser / accessibility / accessibility_events.h
blob8ef9ffed07676eabca04624d08c1c490d78eca6d
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 #ifndef CHROME_BROWSER_ACCESSIBILITY_ACCESSIBILITY_EVENTS_H_
6 #define CHROME_BROWSER_ACCESSIBILITY_ACCESSIBILITY_EVENTS_H_
8 #include <string>
9 #include "base/compiler_specific.h"
10 #include "ui/accessibility/ax_enums.h"
12 class AccessibilityControlInfo;
13 class AccessibilityMenuInfo;
14 class AccessibilityWindowInfo;
15 class Profile;
17 namespace base {
18 class DictionaryValue;
21 // Notify the ExtensionAccessibilityEventRouter of the given accessibility
22 // event and AccessibilityEventInfo details. Will not send if the profile's
23 // pause level is nonzero (using profile->PauseAccessibilityEvents).
24 void SendControlAccessibilityNotification(
25 ui::AXEvent event,
26 AccessibilityControlInfo* info);
28 void SendMenuAccessibilityNotification(
29 ui::AXEvent event,
30 AccessibilityMenuInfo* info);
32 void SendWindowAccessibilityNotification(
33 ui::AXEvent event,
34 AccessibilityWindowInfo* info);
36 // Abstract parent class for accessibility event information passed to event
37 // listeners.
38 class AccessibilityEventInfo {
39 public:
40 virtual ~AccessibilityEventInfo() {}
42 // Serialize this class as a DictionaryValue that can be converted to
43 // a JavaScript object.
44 virtual void SerializeToDict(base::DictionaryValue* dict) const = 0;
46 Profile* profile() const { return profile_; }
48 protected:
49 explicit AccessibilityEventInfo(Profile* profile) : profile_(profile) {}
51 // The profile this control belongs to.
52 Profile* profile_;
55 // Abstract parent class for accessibility information about a control
56 // passed to event listeners.
57 class AccessibilityControlInfo : public AccessibilityEventInfo {
58 public:
59 virtual ~AccessibilityControlInfo();
61 // Serialize this class as a DictionaryValue that can be converted to
62 // a JavaScript object.
63 virtual void SerializeToDict(base::DictionaryValue* dict) const OVERRIDE;
65 // Return the specific type of this control, which will be one of the
66 // string constants defined in extension_accessibility_api_constants.h.
67 virtual const char* type() const = 0;
69 const std::string& name() const { return name_; }
71 const std::string& context() const { return context_; }
73 protected:
74 AccessibilityControlInfo(Profile* profile,
75 const std::string& name);
77 void set_context(const std::string& context) { context_ = context; }
79 // The name of the control, like "OK" or "Password".
80 std::string name_;
82 // A string describing the context of the control, such as the name of
83 // the group or toolbar it's contained in.
84 std::string context_;
87 // Accessibility information about a window passed to onWindowOpened
88 // and onWindowClosed event listeners.
89 class AccessibilityWindowInfo : public AccessibilityControlInfo {
90 public:
91 AccessibilityWindowInfo(Profile* profile, const std::string& window_name);
93 virtual const char* type() const OVERRIDE;
96 // Accessibility information about a push button passed to onControlFocused
97 // and onControlAction event listeners.
98 class AccessibilityButtonInfo : public AccessibilityControlInfo {
99 public:
100 AccessibilityButtonInfo(Profile* profile,
101 const std::string& button_name,
102 const std::string& context);
104 virtual const char* type() const OVERRIDE;
107 // Accessibility information about static text passed to onControlFocused
108 // and onControlAction event listeners.
109 class AccessibilityStaticTextInfo : public AccessibilityControlInfo {
110 public:
111 AccessibilityStaticTextInfo(Profile* profile,
112 const std::string& text,
113 const std::string& context);
115 virtual const char* type() const OVERRIDE;
118 // Accessibility information about a hyperlink passed to onControlFocused
119 // and onControlAction event listeners.
120 class AccessibilityLinkInfo : public AccessibilityControlInfo {
121 public:
122 AccessibilityLinkInfo(Profile* profile,
123 const std::string& link_name,
124 const std::string& context);
126 virtual const char* type() const OVERRIDE;
129 // Accessibility information about a radio button passed to onControlFocused
130 // and onControlAction event listeners.
131 class AccessibilityRadioButtonInfo : public AccessibilityControlInfo {
132 public:
133 AccessibilityRadioButtonInfo(Profile* profile,
134 const std::string& name,
135 const std::string& context,
136 bool checked,
137 int item_index,
138 int item_count);
140 virtual const char* type() const OVERRIDE;
142 virtual void SerializeToDict(base::DictionaryValue* dict) const OVERRIDE;
144 void SetChecked(bool checked) { checked_ = checked; }
146 int item_index() const { return item_index_; }
147 int item_count() const { return item_count_; }
148 bool checked() const { return checked_; }
150 private:
151 bool checked_;
152 // The 0-based index of this radio button and number of buttons in the group.
153 int item_index_;
154 int item_count_;
157 // Accessibility information about a checkbox passed to onControlFocused
158 // and onControlAction event listeners.
159 class AccessibilityCheckboxInfo : public AccessibilityControlInfo {
160 public:
161 AccessibilityCheckboxInfo(Profile* profile,
162 const std::string& name,
163 const std::string& context,
164 bool checked);
166 virtual const char* type() const OVERRIDE;
168 virtual void SerializeToDict(base::DictionaryValue* dict) const OVERRIDE;
170 void SetChecked(bool checked) { checked_ = checked; }
172 bool checked() const { return checked_; }
174 private:
175 bool checked_;
178 // Accessibility information about a tab passed to onControlFocused
179 // and onControlAction event listeners.
180 class AccessibilityTabInfo : public AccessibilityControlInfo {
181 public:
182 AccessibilityTabInfo(Profile* profile,
183 const std::string& tab_name,
184 const std::string& context,
185 int tab_index,
186 int tab_count);
188 virtual const char* type() const OVERRIDE;
190 virtual void SerializeToDict(base::DictionaryValue* dict) const OVERRIDE;
192 void SetTab(int tab_index, std::string tab_name) {
193 tab_index_ = tab_index;
194 name_ = tab_name;
197 int tab_index() const { return tab_index_; }
198 int tab_count() const { return tab_count_; }
200 private:
201 // The 0-based index of this tab and number of tabs in the group.
202 int tab_index_;
203 int tab_count_;
206 // Accessibility information about a combo box passed to onControlFocused
207 // and onControlAction event listeners.
208 class AccessibilityComboBoxInfo : public AccessibilityControlInfo {
209 public:
210 AccessibilityComboBoxInfo(Profile* profile,
211 const std::string& name,
212 const std::string& context,
213 const std::string& value,
214 int item_index,
215 int item_count);
217 virtual const char* type() const OVERRIDE;
219 virtual void SerializeToDict(base::DictionaryValue* dict) const OVERRIDE;
221 void SetValue(int item_index, const std::string& value) {
222 item_index_ = item_index;
223 value_ = value;
226 int item_index() const { return item_index_; }
227 int item_count() const { return item_count_; }
228 const std::string& value() const { return value_; }
230 private:
231 std::string value_;
232 // The 0-based index of the current item and the number of total items.
233 // If the value is not one of the drop-down options, |item_index_| should
234 // be -1.
235 int item_index_;
236 int item_count_;
240 // Accessibility information about a text box, passed to onControlFocused,
241 // onControlAction, and onTextChanged event listeners.
242 class AccessibilityTextBoxInfo : public AccessibilityControlInfo {
243 public:
244 AccessibilityTextBoxInfo(Profile* profile,
245 const std::string& name,
246 const std::string& context,
247 bool password);
249 virtual const char* type() const OVERRIDE;
251 virtual void SerializeToDict(base::DictionaryValue* dict) const OVERRIDE;
253 void SetValue(
254 const std::string& value, int selection_start, int selection_end) {
255 value_ = value;
256 selection_start_ = selection_start;
257 selection_end_ = selection_end;
260 const std::string& value() const { return value_; }
261 bool password() const { return password_; }
262 int selection_start() const { return selection_start_; }
263 int selection_end() const { return selection_end_; }
265 private:
266 std::string value_;
267 bool password_;
268 int selection_start_;
269 int selection_end_;
272 // Accessibility information about a combo box passed to onControlFocused
273 // and onControlAction event listeners.
274 class AccessibilityListBoxInfo : public AccessibilityControlInfo {
275 public:
276 AccessibilityListBoxInfo(Profile* profile,
277 const std::string& name,
278 const std::string& context,
279 const std::string& value,
280 int item_index,
281 int item_count);
283 virtual const char* type() const OVERRIDE;
285 virtual void SerializeToDict(base::DictionaryValue* dict) const OVERRIDE;
287 void SetValue(int item_index, std::string value) {
288 item_index_ = item_index;
289 value_ = value;
292 int item_index() const { return item_index_; }
293 int item_count() const { return item_count_; }
294 const std::string& value() const { return value_; }
296 private:
297 std::string value_;
298 // The 0-based index of the current item and the number of total items.
299 // If the value is not one of the drop-down options, |item_index_| should
300 // be -1.
301 int item_index_;
302 int item_count_;
305 // Accessibility information about a menu; this class is used by
306 // onMenuOpened, onMenuClosed, and onControlFocused event listeners.
307 class AccessibilityMenuInfo : public AccessibilityControlInfo {
308 public:
309 AccessibilityMenuInfo(Profile* profile, const std::string& menu_name);
311 virtual const char* type() const OVERRIDE;
314 // Accessibility information about a menu item; this class is used by
315 // onControlFocused event listeners.
316 class AccessibilityMenuItemInfo : public AccessibilityControlInfo {
317 public:
318 AccessibilityMenuItemInfo(Profile* profile,
319 const std::string& name,
320 const std::string& context,
321 bool has_submenu,
322 int item_index,
323 int item_count);
325 virtual const char* type() const OVERRIDE;
327 virtual void SerializeToDict(base::DictionaryValue* dict) const OVERRIDE;
329 int item_index() const { return item_index_; }
330 int item_count() const { return item_count_; }
331 bool has_submenu() const { return has_submenu_; }
333 private:
334 bool has_submenu_;
335 // The 0-based index of the current item and the number of total items.
336 int item_index_;
337 int item_count_;
340 // Accessibility information about a tree; this class is used by
341 // onControlFocused event listeners.
342 class AccessibilityTreeInfo : public AccessibilityControlInfo {
343 public:
344 AccessibilityTreeInfo(Profile* profile, const std::string& menu_name);
346 virtual const char* type() const OVERRIDE;
349 // Accessibility information about a tree item; this class is used by
350 // onControlFocused event listeners.
351 class AccessibilityTreeItemInfo : public AccessibilityControlInfo {
352 public:
353 AccessibilityTreeItemInfo(Profile* profile,
354 const std::string& name,
355 const std::string& context,
356 int item_depth,
357 int item_index,
358 int item_count,
359 int children_count,
360 bool is_expanded);
362 virtual const char* type() const OVERRIDE;
364 virtual void SerializeToDict(base::DictionaryValue* dict) const OVERRIDE;
366 int item_depth() const { return item_depth_; }
367 int item_index() const { return item_index_; }
368 int item_count() const { return item_count_; }
369 int children_count() const { return children_count_; }
370 bool is_expanded() const { return is_expanded_; }
372 private:
373 // 0-based item depth.
374 int item_depth_;
375 // The 0-based index of the current item and the number of total items at the
376 // current depth.
377 int item_index_;
378 // Count of items at the current depth.
379 int item_count_;
380 // Count of children of the current item.
381 int children_count_;
382 // True if the node is expanded.
383 bool is_expanded_;
386 // Accessibility information about a slider passed to onControlFocused
387 // and onControlAction event listeners.
388 class AccessibilitySliderInfo : public AccessibilityControlInfo {
389 public:
390 AccessibilitySliderInfo(Profile* profile,
391 const std::string& name,
392 const std::string& context,
393 const std::string& value);
395 virtual const char* type() const OVERRIDE;
397 virtual void SerializeToDict(base::DictionaryValue* dict) const OVERRIDE;
399 const std::string& value() const { return value_; }
401 private:
402 std::string value_;
405 // Accessibility information about an alert passed to onControlAction event.
406 class AccessibilityAlertInfo : public AccessibilityControlInfo {
407 public:
408 AccessibilityAlertInfo(Profile* profile, const std::string& name);
410 virtual const char* type() const OVERRIDE;
413 #endif // CHROME_BROWSER_ACCESSIBILITY_ACCESSIBILITY_EVENTS_H_