OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_ACCESSIBILITY_ACCESSIBILITY_EVENTS_H_ | 5 #ifndef CHROME_BROWSER_ACCESSIBILITY_ACCESSIBILITY_EVENTS_H_ |
6 #define CHROME_BROWSER_ACCESSIBILITY_ACCESSIBILITY_EVENTS_H_ | 6 #define CHROME_BROWSER_ACCESSIBILITY_ACCESSIBILITY_EVENTS_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 // Serialize this class as a DictionaryValue that can be converted to | 52 // Serialize this class as a DictionaryValue that can be converted to |
53 // a JavaScript object. | 53 // a JavaScript object. |
54 virtual void SerializeToDict(base::DictionaryValue* dict) const OVERRIDE; | 54 virtual void SerializeToDict(base::DictionaryValue* dict) const OVERRIDE; |
55 | 55 |
56 // Return the specific type of this control, which will be one of the | 56 // Return the specific type of this control, which will be one of the |
57 // string constants defined in extension_accessibility_api_constants.h. | 57 // string constants defined in extension_accessibility_api_constants.h. |
58 virtual const char* type() const = 0; | 58 virtual const char* type() const = 0; |
59 | 59 |
60 const std::string& name() const { return name_; } | 60 const std::string& name() const { return name_; } |
61 | 61 |
| 62 const std::string& context() const { return context_; } |
| 63 |
62 protected: | 64 protected: |
63 AccessibilityControlInfo(Profile* profile, const std::string& control_name); | 65 AccessibilityControlInfo(Profile* profile, |
| 66 const std::string& name, |
| 67 const std::string& context); |
64 | 68 |
65 // The name of the control, like "OK" or "Password". | 69 // The name of the control, like "OK" or "Password". |
66 std::string name_; | 70 std::string name_; |
| 71 |
| 72 // A string describing the context of the control, such as the name of |
| 73 // the group or toolbar it's contained in. |
| 74 std::string context_; |
67 }; | 75 }; |
68 | 76 |
69 // Accessibility information about a window passed to onWindowOpened | 77 // Accessibility information about a window passed to onWindowOpened |
70 // and onWindowClosed event listeners. | 78 // and onWindowClosed event listeners. |
71 class AccessibilityWindowInfo : public AccessibilityControlInfo { | 79 class AccessibilityWindowInfo : public AccessibilityControlInfo { |
72 public: | 80 public: |
73 AccessibilityWindowInfo(Profile* profile, const std::string& window_name); | 81 AccessibilityWindowInfo(Profile* profile, const std::string& window_name); |
74 | 82 |
75 virtual const char* type() const OVERRIDE; | 83 virtual const char* type() const OVERRIDE; |
76 }; | 84 }; |
77 | 85 |
78 // Accessibility information about a push button passed to onControlFocused | 86 // Accessibility information about a push button passed to onControlFocused |
79 // and onControlAction event listeners. | 87 // and onControlAction event listeners. |
80 class AccessibilityButtonInfo : public AccessibilityControlInfo { | 88 class AccessibilityButtonInfo : public AccessibilityControlInfo { |
81 public: | 89 public: |
82 AccessibilityButtonInfo(Profile* profile, const std::string& button_name); | 90 AccessibilityButtonInfo(Profile* profile, |
| 91 const std::string& button_name, |
| 92 const std::string& context); |
83 | 93 |
84 virtual const char* type() const OVERRIDE; | 94 virtual const char* type() const OVERRIDE; |
85 }; | 95 }; |
86 | 96 |
87 // Accessibility information about a hyperlink passed to onControlFocused | 97 // Accessibility information about a hyperlink passed to onControlFocused |
88 // and onControlAction event listeners. | 98 // and onControlAction event listeners. |
89 class AccessibilityLinkInfo : public AccessibilityControlInfo { | 99 class AccessibilityLinkInfo : public AccessibilityControlInfo { |
90 public: | 100 public: |
91 AccessibilityLinkInfo(Profile* profile, const std::string& link_name); | 101 AccessibilityLinkInfo(Profile* profile, |
| 102 const std::string& link_name, |
| 103 const std::string& context); |
92 | 104 |
93 virtual const char* type() const OVERRIDE; | 105 virtual const char* type() const OVERRIDE; |
94 }; | 106 }; |
95 | 107 |
96 // Accessibility information about a radio button passed to onControlFocused | 108 // Accessibility information about a radio button passed to onControlFocused |
97 // and onControlAction event listeners. | 109 // and onControlAction event listeners. |
98 class AccessibilityRadioButtonInfo : public AccessibilityControlInfo { | 110 class AccessibilityRadioButtonInfo : public AccessibilityControlInfo { |
99 public: | 111 public: |
100 AccessibilityRadioButtonInfo(Profile* profile, | 112 AccessibilityRadioButtonInfo(Profile* profile, |
101 const std::string& name, | 113 const std::string& name, |
| 114 const std::string& context, |
102 bool checked, | 115 bool checked, |
103 int item_index, | 116 int item_index, |
104 int item_count); | 117 int item_count); |
105 | 118 |
106 virtual const char* type() const OVERRIDE; | 119 virtual const char* type() const OVERRIDE; |
107 | 120 |
108 virtual void SerializeToDict(base::DictionaryValue* dict) const OVERRIDE; | 121 virtual void SerializeToDict(base::DictionaryValue* dict) const OVERRIDE; |
109 | 122 |
110 void SetChecked(bool checked) { checked_ = checked; } | 123 void SetChecked(bool checked) { checked_ = checked; } |
111 | 124 |
112 int item_index() const { return item_index_; } | 125 int item_index() const { return item_index_; } |
113 int item_count() const { return item_count_; } | 126 int item_count() const { return item_count_; } |
114 bool checked() const { return checked_; } | 127 bool checked() const { return checked_; } |
115 | 128 |
116 private: | 129 private: |
117 bool checked_; | 130 bool checked_; |
118 // The 0-based index of this radio button and number of buttons in the group. | 131 // The 0-based index of this radio button and number of buttons in the group. |
119 int item_index_; | 132 int item_index_; |
120 int item_count_; | 133 int item_count_; |
121 }; | 134 }; |
122 | 135 |
123 // Accessibility information about a checkbox passed to onControlFocused | 136 // Accessibility information about a checkbox passed to onControlFocused |
124 // and onControlAction event listeners. | 137 // and onControlAction event listeners. |
125 class AccessibilityCheckboxInfo : public AccessibilityControlInfo { | 138 class AccessibilityCheckboxInfo : public AccessibilityControlInfo { |
126 public: | 139 public: |
127 AccessibilityCheckboxInfo(Profile* profile, | 140 AccessibilityCheckboxInfo(Profile* profile, |
128 const std::string& name, | 141 const std::string& name, |
| 142 const std::string& context, |
129 bool checked); | 143 bool checked); |
130 | 144 |
131 virtual const char* type() const OVERRIDE; | 145 virtual const char* type() const OVERRIDE; |
132 | 146 |
133 virtual void SerializeToDict(base::DictionaryValue* dict) const OVERRIDE; | 147 virtual void SerializeToDict(base::DictionaryValue* dict) const OVERRIDE; |
134 | 148 |
135 void SetChecked(bool checked) { checked_ = checked; } | 149 void SetChecked(bool checked) { checked_ = checked; } |
136 | 150 |
137 bool checked() const { return checked_; } | 151 bool checked() const { return checked_; } |
138 | 152 |
139 private: | 153 private: |
140 bool checked_; | 154 bool checked_; |
141 }; | 155 }; |
142 | 156 |
143 // Accessibility information about a tab passed to onControlFocused | 157 // Accessibility information about a tab passed to onControlFocused |
144 // and onControlAction event listeners. | 158 // and onControlAction event listeners. |
145 class AccessibilityTabInfo : public AccessibilityControlInfo { | 159 class AccessibilityTabInfo : public AccessibilityControlInfo { |
146 public: | 160 public: |
147 AccessibilityTabInfo(Profile* profile, | 161 AccessibilityTabInfo(Profile* profile, |
148 const std::string& tab_name, | 162 const std::string& tab_name, |
| 163 const std::string& context, |
149 int tab_index, | 164 int tab_index, |
150 int tab_count); | 165 int tab_count); |
151 | 166 |
152 virtual const char* type() const OVERRIDE; | 167 virtual const char* type() const OVERRIDE; |
153 | 168 |
154 virtual void SerializeToDict(base::DictionaryValue* dict) const OVERRIDE; | 169 virtual void SerializeToDict(base::DictionaryValue* dict) const OVERRIDE; |
155 | 170 |
156 void SetTab(int tab_index, std::string tab_name) { | 171 void SetTab(int tab_index, std::string tab_name) { |
157 tab_index_ = tab_index; | 172 tab_index_ = tab_index; |
158 name_ = tab_name; | 173 name_ = tab_name; |
159 } | 174 } |
160 | 175 |
161 int tab_index() const { return tab_index_; } | 176 int tab_index() const { return tab_index_; } |
162 int tab_count() const { return tab_count_; } | 177 int tab_count() const { return tab_count_; } |
163 | 178 |
164 private: | 179 private: |
165 // The 0-based index of this tab and number of tabs in the group. | 180 // The 0-based index of this tab and number of tabs in the group. |
166 int tab_index_; | 181 int tab_index_; |
167 int tab_count_; | 182 int tab_count_; |
168 }; | 183 }; |
169 | 184 |
170 // Accessibility information about a combo box passed to onControlFocused | 185 // Accessibility information about a combo box passed to onControlFocused |
171 // and onControlAction event listeners. | 186 // and onControlAction event listeners. |
172 class AccessibilityComboBoxInfo : public AccessibilityControlInfo { | 187 class AccessibilityComboBoxInfo : public AccessibilityControlInfo { |
173 public: | 188 public: |
174 AccessibilityComboBoxInfo(Profile* profile, | 189 AccessibilityComboBoxInfo(Profile* profile, |
175 const std::string& name, | 190 const std::string& name, |
| 191 const std::string& context, |
176 const std::string& value, | 192 const std::string& value, |
177 int item_index, | 193 int item_index, |
178 int item_count); | 194 int item_count); |
179 | 195 |
180 virtual const char* type() const OVERRIDE; | 196 virtual const char* type() const OVERRIDE; |
181 | 197 |
182 virtual void SerializeToDict(base::DictionaryValue* dict) const OVERRIDE; | 198 virtual void SerializeToDict(base::DictionaryValue* dict) const OVERRIDE; |
183 | 199 |
184 void SetValue(int item_index, const std::string& value) { | 200 void SetValue(int item_index, const std::string& value) { |
185 item_index_ = item_index; | 201 item_index_ = item_index; |
(...skipping 12 matching lines...) Expand all Loading... |
198 int item_index_; | 214 int item_index_; |
199 int item_count_; | 215 int item_count_; |
200 }; | 216 }; |
201 | 217 |
202 // Accessibility information about a text box, passed to onControlFocused, | 218 // Accessibility information about a text box, passed to onControlFocused, |
203 // onControlAction, and onTextChanged event listeners. | 219 // onControlAction, and onTextChanged event listeners. |
204 class AccessibilityTextBoxInfo : public AccessibilityControlInfo { | 220 class AccessibilityTextBoxInfo : public AccessibilityControlInfo { |
205 public: | 221 public: |
206 AccessibilityTextBoxInfo(Profile* profile, | 222 AccessibilityTextBoxInfo(Profile* profile, |
207 const std::string& name, | 223 const std::string& name, |
| 224 const std::string& context, |
208 bool password); | 225 bool password); |
209 | 226 |
210 virtual const char* type() const OVERRIDE; | 227 virtual const char* type() const OVERRIDE; |
211 | 228 |
212 virtual void SerializeToDict(base::DictionaryValue* dict) const OVERRIDE; | 229 virtual void SerializeToDict(base::DictionaryValue* dict) const OVERRIDE; |
213 | 230 |
214 void SetValue( | 231 void SetValue( |
215 const std::string& value, int selection_start, int selection_end) { | 232 const std::string& value, int selection_start, int selection_end) { |
216 value_ = value; | 233 value_ = value; |
217 selection_start_ = selection_start; | 234 selection_start_ = selection_start; |
(...skipping 11 matching lines...) Expand all Loading... |
229 int selection_start_; | 246 int selection_start_; |
230 int selection_end_; | 247 int selection_end_; |
231 }; | 248 }; |
232 | 249 |
233 // Accessibility information about a combo box passed to onControlFocused | 250 // Accessibility information about a combo box passed to onControlFocused |
234 // and onControlAction event listeners. | 251 // and onControlAction event listeners. |
235 class AccessibilityListBoxInfo : public AccessibilityControlInfo { | 252 class AccessibilityListBoxInfo : public AccessibilityControlInfo { |
236 public: | 253 public: |
237 AccessibilityListBoxInfo(Profile* profile, | 254 AccessibilityListBoxInfo(Profile* profile, |
238 const std::string& name, | 255 const std::string& name, |
| 256 const std::string& context, |
239 const std::string& value, | 257 const std::string& value, |
240 int item_index, | 258 int item_index, |
241 int item_count); | 259 int item_count); |
242 | 260 |
243 virtual const char* type() const OVERRIDE; | 261 virtual const char* type() const OVERRIDE; |
244 | 262 |
245 virtual void SerializeToDict(base::DictionaryValue* dict) const OVERRIDE; | 263 virtual void SerializeToDict(base::DictionaryValue* dict) const OVERRIDE; |
246 | 264 |
247 void SetValue(int item_index, std::string value) { | 265 void SetValue(int item_index, std::string value) { |
248 item_index_ = item_index; | 266 item_index_ = item_index; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 explicit WokeUpEventInfo(Profile* profile); | 316 explicit WokeUpEventInfo(Profile* profile); |
299 virtual void SerializeToDict(base::DictionaryValue* dict) const OVERRIDE; | 317 virtual void SerializeToDict(base::DictionaryValue* dict) const OVERRIDE; |
300 }; | 318 }; |
301 | 319 |
302 // Accessibility information about a menu item; this class is used by | 320 // Accessibility information about a menu item; this class is used by |
303 // onControlFocused event listeners. | 321 // onControlFocused event listeners. |
304 class AccessibilityMenuItemInfo : public AccessibilityControlInfo { | 322 class AccessibilityMenuItemInfo : public AccessibilityControlInfo { |
305 public: | 323 public: |
306 AccessibilityMenuItemInfo(Profile* profile, | 324 AccessibilityMenuItemInfo(Profile* profile, |
307 const std::string& name, | 325 const std::string& name, |
| 326 const std::string& context, |
308 bool has_submenu, | 327 bool has_submenu, |
309 int item_index, | 328 int item_index, |
310 int item_count); | 329 int item_count); |
311 | 330 |
312 virtual const char* type() const OVERRIDE; | 331 virtual const char* type() const OVERRIDE; |
313 | 332 |
314 virtual void SerializeToDict(base::DictionaryValue* dict) const OVERRIDE; | 333 virtual void SerializeToDict(base::DictionaryValue* dict) const OVERRIDE; |
315 | 334 |
316 int item_index() const { return item_index_; } | 335 int item_index() const { return item_index_; } |
317 int item_count() const { return item_count_; } | 336 int item_count() const { return item_count_; } |
318 bool has_submenu() const { return has_submenu_; } | 337 bool has_submenu() const { return has_submenu_; } |
319 | 338 |
320 private: | 339 private: |
321 bool has_submenu_; | 340 bool has_submenu_; |
322 // The 0-based index of the current item and the number of total items. | 341 // The 0-based index of the current item and the number of total items. |
323 int item_index_; | 342 int item_index_; |
324 int item_count_; | 343 int item_count_; |
325 }; | 344 }; |
326 | 345 |
327 #endif // CHROME_BROWSER_ACCESSIBILITY_ACCESSIBILITY_EVENTS_H_ | 346 #endif // CHROME_BROWSER_ACCESSIBILITY_ACCESSIBILITY_EVENTS_H_ |
OLD | NEW |