Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(239)

Side by Side Diff: chrome/browser/accessibility/accessibility_events.h

Issue 8850004: Add a context field to the accessibility extension API. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/accessibility/accessibility_events.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
68 void set_context(const std::string& context) { context_ = context; }
64 69
65 // The name of the control, like "OK" or "Password". 70 // The name of the control, like "OK" or "Password".
66 std::string name_; 71 std::string name_;
72
73 // A string describing the context of the control, such as the name of
74 // the group or toolbar it's contained in.
75 std::string context_;
67 }; 76 };
68 77
69 // Accessibility information about a window passed to onWindowOpened 78 // Accessibility information about a window passed to onWindowOpened
70 // and onWindowClosed event listeners. 79 // and onWindowClosed event listeners.
71 class AccessibilityWindowInfo : public AccessibilityControlInfo { 80 class AccessibilityWindowInfo : public AccessibilityControlInfo {
72 public: 81 public:
73 AccessibilityWindowInfo(Profile* profile, const std::string& window_name); 82 AccessibilityWindowInfo(Profile* profile, const std::string& window_name);
74 83
75 virtual const char* type() const OVERRIDE; 84 virtual const char* type() const OVERRIDE;
76 }; 85 };
77 86
78 // Accessibility information about a push button passed to onControlFocused 87 // Accessibility information about a push button passed to onControlFocused
79 // and onControlAction event listeners. 88 // and onControlAction event listeners.
80 class AccessibilityButtonInfo : public AccessibilityControlInfo { 89 class AccessibilityButtonInfo : public AccessibilityControlInfo {
81 public: 90 public:
82 AccessibilityButtonInfo(Profile* profile, const std::string& button_name); 91 AccessibilityButtonInfo(Profile* profile,
92 const std::string& button_name,
93 const std::string& context);
83 94
84 virtual const char* type() const OVERRIDE; 95 virtual const char* type() const OVERRIDE;
85 }; 96 };
86 97
87 // Accessibility information about a hyperlink passed to onControlFocused 98 // Accessibility information about a hyperlink passed to onControlFocused
88 // and onControlAction event listeners. 99 // and onControlAction event listeners.
89 class AccessibilityLinkInfo : public AccessibilityControlInfo { 100 class AccessibilityLinkInfo : public AccessibilityControlInfo {
90 public: 101 public:
91 AccessibilityLinkInfo(Profile* profile, const std::string& link_name); 102 AccessibilityLinkInfo(Profile* profile,
103 const std::string& link_name,
104 const std::string& context);
92 105
93 virtual const char* type() const OVERRIDE; 106 virtual const char* type() const OVERRIDE;
94 }; 107 };
95 108
96 // Accessibility information about a radio button passed to onControlFocused 109 // Accessibility information about a radio button passed to onControlFocused
97 // and onControlAction event listeners. 110 // and onControlAction event listeners.
98 class AccessibilityRadioButtonInfo : public AccessibilityControlInfo { 111 class AccessibilityRadioButtonInfo : public AccessibilityControlInfo {
99 public: 112 public:
100 AccessibilityRadioButtonInfo(Profile* profile, 113 AccessibilityRadioButtonInfo(Profile* profile,
101 const std::string& name, 114 const std::string& name,
115 const std::string& context,
102 bool checked, 116 bool checked,
103 int item_index, 117 int item_index,
104 int item_count); 118 int item_count);
105 119
106 virtual const char* type() const OVERRIDE; 120 virtual const char* type() const OVERRIDE;
107 121
108 virtual void SerializeToDict(base::DictionaryValue* dict) const OVERRIDE; 122 virtual void SerializeToDict(base::DictionaryValue* dict) const OVERRIDE;
109 123
110 void SetChecked(bool checked) { checked_ = checked; } 124 void SetChecked(bool checked) { checked_ = checked; }
111 125
112 int item_index() const { return item_index_; } 126 int item_index() const { return item_index_; }
113 int item_count() const { return item_count_; } 127 int item_count() const { return item_count_; }
114 bool checked() const { return checked_; } 128 bool checked() const { return checked_; }
115 129
116 private: 130 private:
117 bool checked_; 131 bool checked_;
118 // The 0-based index of this radio button and number of buttons in the group. 132 // The 0-based index of this radio button and number of buttons in the group.
119 int item_index_; 133 int item_index_;
120 int item_count_; 134 int item_count_;
121 }; 135 };
122 136
123 // Accessibility information about a checkbox passed to onControlFocused 137 // Accessibility information about a checkbox passed to onControlFocused
124 // and onControlAction event listeners. 138 // and onControlAction event listeners.
125 class AccessibilityCheckboxInfo : public AccessibilityControlInfo { 139 class AccessibilityCheckboxInfo : public AccessibilityControlInfo {
126 public: 140 public:
127 AccessibilityCheckboxInfo(Profile* profile, 141 AccessibilityCheckboxInfo(Profile* profile,
128 const std::string& name, 142 const std::string& name,
143 const std::string& context,
129 bool checked); 144 bool checked);
130 145
131 virtual const char* type() const OVERRIDE; 146 virtual const char* type() const OVERRIDE;
132 147
133 virtual void SerializeToDict(base::DictionaryValue* dict) const OVERRIDE; 148 virtual void SerializeToDict(base::DictionaryValue* dict) const OVERRIDE;
134 149
135 void SetChecked(bool checked) { checked_ = checked; } 150 void SetChecked(bool checked) { checked_ = checked; }
136 151
137 bool checked() const { return checked_; } 152 bool checked() const { return checked_; }
138 153
139 private: 154 private:
140 bool checked_; 155 bool checked_;
141 }; 156 };
142 157
143 // Accessibility information about a tab passed to onControlFocused 158 // Accessibility information about a tab passed to onControlFocused
144 // and onControlAction event listeners. 159 // and onControlAction event listeners.
145 class AccessibilityTabInfo : public AccessibilityControlInfo { 160 class AccessibilityTabInfo : public AccessibilityControlInfo {
146 public: 161 public:
147 AccessibilityTabInfo(Profile* profile, 162 AccessibilityTabInfo(Profile* profile,
148 const std::string& tab_name, 163 const std::string& tab_name,
164 const std::string& context,
149 int tab_index, 165 int tab_index,
150 int tab_count); 166 int tab_count);
151 167
152 virtual const char* type() const OVERRIDE; 168 virtual const char* type() const OVERRIDE;
153 169
154 virtual void SerializeToDict(base::DictionaryValue* dict) const OVERRIDE; 170 virtual void SerializeToDict(base::DictionaryValue* dict) const OVERRIDE;
155 171
156 void SetTab(int tab_index, std::string tab_name) { 172 void SetTab(int tab_index, std::string tab_name) {
157 tab_index_ = tab_index; 173 tab_index_ = tab_index;
158 name_ = tab_name; 174 name_ = tab_name;
159 } 175 }
160 176
161 int tab_index() const { return tab_index_; } 177 int tab_index() const { return tab_index_; }
162 int tab_count() const { return tab_count_; } 178 int tab_count() const { return tab_count_; }
163 179
164 private: 180 private:
165 // The 0-based index of this tab and number of tabs in the group. 181 // The 0-based index of this tab and number of tabs in the group.
166 int tab_index_; 182 int tab_index_;
167 int tab_count_; 183 int tab_count_;
168 }; 184 };
169 185
170 // Accessibility information about a combo box passed to onControlFocused 186 // Accessibility information about a combo box passed to onControlFocused
171 // and onControlAction event listeners. 187 // and onControlAction event listeners.
172 class AccessibilityComboBoxInfo : public AccessibilityControlInfo { 188 class AccessibilityComboBoxInfo : public AccessibilityControlInfo {
173 public: 189 public:
174 AccessibilityComboBoxInfo(Profile* profile, 190 AccessibilityComboBoxInfo(Profile* profile,
175 const std::string& name, 191 const std::string& name,
192 const std::string& context,
176 const std::string& value, 193 const std::string& value,
177 int item_index, 194 int item_index,
178 int item_count); 195 int item_count);
179 196
180 virtual const char* type() const OVERRIDE; 197 virtual const char* type() const OVERRIDE;
181 198
182 virtual void SerializeToDict(base::DictionaryValue* dict) const OVERRIDE; 199 virtual void SerializeToDict(base::DictionaryValue* dict) const OVERRIDE;
183 200
184 void SetValue(int item_index, const std::string& value) { 201 void SetValue(int item_index, const std::string& value) {
185 item_index_ = item_index; 202 item_index_ = item_index;
(...skipping 12 matching lines...) Expand all
198 int item_index_; 215 int item_index_;
199 int item_count_; 216 int item_count_;
200 }; 217 };
201 218
202 // Accessibility information about a text box, passed to onControlFocused, 219 // Accessibility information about a text box, passed to onControlFocused,
203 // onControlAction, and onTextChanged event listeners. 220 // onControlAction, and onTextChanged event listeners.
204 class AccessibilityTextBoxInfo : public AccessibilityControlInfo { 221 class AccessibilityTextBoxInfo : public AccessibilityControlInfo {
205 public: 222 public:
206 AccessibilityTextBoxInfo(Profile* profile, 223 AccessibilityTextBoxInfo(Profile* profile,
207 const std::string& name, 224 const std::string& name,
225 const std::string& context,
208 bool password); 226 bool password);
209 227
210 virtual const char* type() const OVERRIDE; 228 virtual const char* type() const OVERRIDE;
211 229
212 virtual void SerializeToDict(base::DictionaryValue* dict) const OVERRIDE; 230 virtual void SerializeToDict(base::DictionaryValue* dict) const OVERRIDE;
213 231
214 void SetValue( 232 void SetValue(
215 const std::string& value, int selection_start, int selection_end) { 233 const std::string& value, int selection_start, int selection_end) {
216 value_ = value; 234 value_ = value;
217 selection_start_ = selection_start; 235 selection_start_ = selection_start;
(...skipping 11 matching lines...) Expand all
229 int selection_start_; 247 int selection_start_;
230 int selection_end_; 248 int selection_end_;
231 }; 249 };
232 250
233 // Accessibility information about a combo box passed to onControlFocused 251 // Accessibility information about a combo box passed to onControlFocused
234 // and onControlAction event listeners. 252 // and onControlAction event listeners.
235 class AccessibilityListBoxInfo : public AccessibilityControlInfo { 253 class AccessibilityListBoxInfo : public AccessibilityControlInfo {
236 public: 254 public:
237 AccessibilityListBoxInfo(Profile* profile, 255 AccessibilityListBoxInfo(Profile* profile,
238 const std::string& name, 256 const std::string& name,
257 const std::string& context,
239 const std::string& value, 258 const std::string& value,
240 int item_index, 259 int item_index,
241 int item_count); 260 int item_count);
242 261
243 virtual const char* type() const OVERRIDE; 262 virtual const char* type() const OVERRIDE;
244 263
245 virtual void SerializeToDict(base::DictionaryValue* dict) const OVERRIDE; 264 virtual void SerializeToDict(base::DictionaryValue* dict) const OVERRIDE;
246 265
247 void SetValue(int item_index, std::string value) { 266 void SetValue(int item_index, std::string value) {
248 item_index_ = item_index; 267 item_index_ = item_index;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 explicit WokeUpEventInfo(Profile* profile); 317 explicit WokeUpEventInfo(Profile* profile);
299 virtual void SerializeToDict(base::DictionaryValue* dict) const OVERRIDE; 318 virtual void SerializeToDict(base::DictionaryValue* dict) const OVERRIDE;
300 }; 319 };
301 320
302 // Accessibility information about a menu item; this class is used by 321 // Accessibility information about a menu item; this class is used by
303 // onControlFocused event listeners. 322 // onControlFocused event listeners.
304 class AccessibilityMenuItemInfo : public AccessibilityControlInfo { 323 class AccessibilityMenuItemInfo : public AccessibilityControlInfo {
305 public: 324 public:
306 AccessibilityMenuItemInfo(Profile* profile, 325 AccessibilityMenuItemInfo(Profile* profile,
307 const std::string& name, 326 const std::string& name,
327 const std::string& context,
308 bool has_submenu, 328 bool has_submenu,
309 int item_index, 329 int item_index,
310 int item_count); 330 int item_count);
311 331
312 virtual const char* type() const OVERRIDE; 332 virtual const char* type() const OVERRIDE;
313 333
314 virtual void SerializeToDict(base::DictionaryValue* dict) const OVERRIDE; 334 virtual void SerializeToDict(base::DictionaryValue* dict) const OVERRIDE;
315 335
316 int item_index() const { return item_index_; } 336 int item_index() const { return item_index_; }
317 int item_count() const { return item_count_; } 337 int item_count() const { return item_count_; }
318 bool has_submenu() const { return has_submenu_; } 338 bool has_submenu() const { return has_submenu_; }
319 339
320 private: 340 private:
321 bool has_submenu_; 341 bool has_submenu_;
322 // The 0-based index of the current item and the number of total items. 342 // The 0-based index of the current item and the number of total items.
323 int item_index_; 343 int item_index_;
324 int item_count_; 344 int item_count_;
325 }; 345 };
326 346
327 #endif // CHROME_BROWSER_ACCESSIBILITY_ACCESSIBILITY_EVENTS_H_ 347 #endif // CHROME_BROWSER_ACCESSIBILITY_ACCESSIBILITY_EVENTS_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/accessibility/accessibility_events.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698