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

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

Issue 3073026: Expose the type of an AccessibilityControlInfo. (This will allow us... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 4 months 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_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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_EVENTS_H_ 5 #ifndef CHROME_BROWSER_ACCESSIBILITY_EVENTS_H_
6 #define CHROME_BROWSER_ACCESSIBILITY_EVENTS_H_ 6 #define CHROME_BROWSER_ACCESSIBILITY_EVENTS_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 13 matching lines...) Expand all
24 // Abstract parent class for accessibility information about a control 24 // Abstract parent class for accessibility information about a control
25 // passed to event listeners. 25 // passed to event listeners.
26 class AccessibilityControlInfo { 26 class AccessibilityControlInfo {
27 public: 27 public:
28 virtual ~AccessibilityControlInfo() { } 28 virtual ~AccessibilityControlInfo() { }
29 29
30 // Serialize this class as a DictionaryValue that can be converted to 30 // Serialize this class as a DictionaryValue that can be converted to
31 // a JavaScript object. 31 // a JavaScript object.
32 virtual void SerializeToDict(DictionaryValue *dict) const; 32 virtual void SerializeToDict(DictionaryValue *dict) const;
33 33
34 // Return the specific type of this control, which will be one of the
35 // string constants defined in extension_accessibility_api_constants.h.
36 virtual const char* type() const = 0;
37
34 Profile* profile() const { return profile_; } 38 Profile* profile() const { return profile_; }
35 39
36 const std::string& name() const { return name_; } 40 const std::string& name() const { return name_; }
37 41
38 protected: 42 protected:
39 // The constructor can only be called by subclasses. 43 // The constructor can only be called by subclasses.
40 AccessibilityControlInfo(Profile* profile, std::string control_name) 44 AccessibilityControlInfo(Profile* profile, std::string control_name)
41 : profile_(profile), name_(control_name) { } 45 : profile_(profile), name_(control_name) { }
42 46
43 // The profile this control belongs to. 47 // The profile this control belongs to.
44 Profile* profile_; 48 Profile* profile_;
45 49
46 // The name of the control, like "OK" or "Password". 50 // The name of the control, like "OK" or "Password".
47 std::string name_; 51 std::string name_;
48 }; 52 };
49 53
50 // Accessibility information about a window passed to onWindowOpened 54 // Accessibility information about a window passed to onWindowOpened
51 // and onWindowClosed event listeners. 55 // and onWindowClosed event listeners.
52 class AccessibilityWindowInfo : public AccessibilityControlInfo { 56 class AccessibilityWindowInfo : public AccessibilityControlInfo {
53 public: 57 public:
54 AccessibilityWindowInfo(Profile* profile, std::string window_name) 58 AccessibilityWindowInfo(Profile* profile, std::string window_name)
55 : AccessibilityControlInfo(profile, window_name) { } 59 : AccessibilityControlInfo(profile, window_name) { }
56 60
57 virtual void SerializeToDict(DictionaryValue *dict) const; 61 virtual const char* type() const;
58 }; 62 };
59 63
60 // Accessibility information about a push button passed to onControlFocused 64 // Accessibility information about a push button passed to onControlFocused
61 // and onControlAction event listeners. 65 // and onControlAction event listeners.
62 class AccessibilityButtonInfo : public AccessibilityControlInfo { 66 class AccessibilityButtonInfo : public AccessibilityControlInfo {
63 public: 67 public:
64 AccessibilityButtonInfo(Profile* profile, std::string button_name) 68 AccessibilityButtonInfo(Profile* profile, std::string button_name)
65 : AccessibilityControlInfo(profile, button_name) { } 69 : AccessibilityControlInfo(profile, button_name) { }
66 70
67 virtual void SerializeToDict(DictionaryValue *dict) const; 71 virtual const char* type() const;
68 }; 72 };
69 73
70 // Accessibility information about a hyperlink passed to onControlFocused 74 // Accessibility information about a hyperlink passed to onControlFocused
71 // and onControlAction event listeners. 75 // and onControlAction event listeners.
72 class AccessibilityLinkInfo : public AccessibilityControlInfo { 76 class AccessibilityLinkInfo : public AccessibilityControlInfo {
73 public: 77 public:
74 AccessibilityLinkInfo(Profile* profile, std::string link_name) 78 AccessibilityLinkInfo(Profile* profile, std::string link_name)
75 : AccessibilityControlInfo(profile, link_name) { } 79 : AccessibilityControlInfo(profile, link_name) { }
76 80
77 virtual void SerializeToDict(DictionaryValue *dict) const; 81 virtual const char* type() const;
78 }; 82 };
79 83
80 // Accessibility information about a radio button passed to onControlFocused 84 // Accessibility information about a radio button passed to onControlFocused
81 // and onControlAction event listeners. 85 // and onControlAction event listeners.
82 class AccessibilityRadioButtonInfo : public AccessibilityControlInfo { 86 class AccessibilityRadioButtonInfo : public AccessibilityControlInfo {
83 public: 87 public:
84 AccessibilityRadioButtonInfo(Profile* profile, 88 AccessibilityRadioButtonInfo(Profile* profile,
85 std::string name, 89 std::string name,
86 bool checked, 90 bool checked,
87 int item_index, 91 int item_index,
88 int item_count) 92 int item_count)
89 : AccessibilityControlInfo(profile, name), 93 : AccessibilityControlInfo(profile, name),
90 checked_(checked), 94 checked_(checked),
91 item_index_(item_index), 95 item_index_(item_index),
92 item_count_(item_count) { 96 item_count_(item_count) {
93 } 97 }
94 98
99 virtual const char* type() const;
100
95 virtual void SerializeToDict(DictionaryValue *dict) const; 101 virtual void SerializeToDict(DictionaryValue *dict) const;
96 102
97 void SetChecked(bool checked) { checked_ = checked; } 103 void SetChecked(bool checked) { checked_ = checked; }
98 104
99 private: 105 private:
100 bool checked_; 106 bool checked_;
101 // The 0-based index of this radio button and number of buttons in the group. 107 // The 0-based index of this radio button and number of buttons in the group.
102 int item_index_; 108 int item_index_;
103 int item_count_; 109 int item_count_;
104 }; 110 };
105 111
106 // Accessibility information about a checkbox passed to onControlFocused 112 // Accessibility information about a checkbox passed to onControlFocused
107 // and onControlAction event listeners. 113 // and onControlAction event listeners.
108 class AccessibilityCheckboxInfo : public AccessibilityControlInfo { 114 class AccessibilityCheckboxInfo : public AccessibilityControlInfo {
109 public: 115 public:
110 AccessibilityCheckboxInfo(Profile* profile, 116 AccessibilityCheckboxInfo(Profile* profile,
111 std::string name, 117 std::string name,
112 bool checked) 118 bool checked)
113 : AccessibilityControlInfo(profile, name), 119 : AccessibilityControlInfo(profile, name),
114 checked_(checked) { 120 checked_(checked) {
115 } 121 }
116 122
123 virtual const char* type() const;
124
117 virtual void SerializeToDict(DictionaryValue *dict) const; 125 virtual void SerializeToDict(DictionaryValue *dict) const;
118 126
119 void SetChecked(bool checked) { checked_ = checked; } 127 void SetChecked(bool checked) { checked_ = checked; }
120 128
121 private: 129 private:
122 bool checked_; 130 bool checked_;
123 }; 131 };
124 132
125 // Accessibility information about a tab passed to onControlFocused 133 // Accessibility information about a tab passed to onControlFocused
126 // and onControlAction event listeners. 134 // and onControlAction event listeners.
127 class AccessibilityTabInfo : public AccessibilityControlInfo { 135 class AccessibilityTabInfo : public AccessibilityControlInfo {
128 public: 136 public:
129 AccessibilityTabInfo(Profile* profile, 137 AccessibilityTabInfo(Profile* profile,
130 std::string tab_name, 138 std::string tab_name,
131 int tab_index, 139 int tab_index,
132 int tab_count) 140 int tab_count)
133 : AccessibilityControlInfo(profile, tab_name), 141 : AccessibilityControlInfo(profile, tab_name),
134 tab_index_(tab_index), 142 tab_index_(tab_index),
135 tab_count_(tab_count) { 143 tab_count_(tab_count) {
136 } 144 }
137 145
146 virtual const char* type() const;
147
138 virtual void SerializeToDict(DictionaryValue *dict) const; 148 virtual void SerializeToDict(DictionaryValue *dict) const;
139 149
140 void SetTab(int tab_index, std::string tab_name) { 150 void SetTab(int tab_index, std::string tab_name) {
141 tab_index_ = tab_index; 151 tab_index_ = tab_index;
142 name_ = tab_name; 152 name_ = tab_name;
143 } 153 }
144 154
145 private: 155 private:
146 // The 0-based index of this tab and number of tabs in the group. 156 // The 0-based index of this tab and number of tabs in the group.
147 int tab_index_; 157 int tab_index_;
148 int tab_count_; 158 int tab_count_;
149 }; 159 };
150 160
151 // Accessibility information about a combo box passed to onControlFocused 161 // Accessibility information about a combo box passed to onControlFocused
152 // and onControlAction event listeners. 162 // and onControlAction event listeners.
153 class AccessibilityComboBoxInfo : public AccessibilityControlInfo { 163 class AccessibilityComboBoxInfo : public AccessibilityControlInfo {
154 public: 164 public:
155 AccessibilityComboBoxInfo(Profile* profile, 165 AccessibilityComboBoxInfo(Profile* profile,
156 std::string name, 166 std::string name,
157 std::string value, 167 std::string value,
158 int item_index, 168 int item_index,
159 int item_count) 169 int item_count)
160 : AccessibilityControlInfo(profile, name), 170 : AccessibilityControlInfo(profile, name),
161 value_(value), 171 value_(value),
162 item_index_(item_index), 172 item_index_(item_index),
163 item_count_(item_count) { 173 item_count_(item_count) {
164 } 174 }
165 175
176 virtual const char* type() const;
177
166 virtual void SerializeToDict(DictionaryValue *dict) const; 178 virtual void SerializeToDict(DictionaryValue *dict) const;
167 179
168 void SetValue(int item_index, std::string value) { 180 void SetValue(int item_index, std::string value) {
169 item_index_ = item_index; 181 item_index_ = item_index;
170 value_ = value; 182 value_ = value;
171 } 183 }
172 184
173 private: 185 private:
174 std::string value_; 186 std::string value_;
175 // The 0-based index of the current item and the number of total items. 187 // The 0-based index of the current item and the number of total items.
(...skipping 10 matching lines...) Expand all
186 AccessibilityTextBoxInfo(Profile* profile, 198 AccessibilityTextBoxInfo(Profile* profile,
187 std::string name, 199 std::string name,
188 bool password) 200 bool password)
189 : AccessibilityControlInfo(profile, name), 201 : AccessibilityControlInfo(profile, name),
190 value_(""), 202 value_(""),
191 password_(password), 203 password_(password),
192 selection_start_(0), 204 selection_start_(0),
193 selection_end_(0) { 205 selection_end_(0) {
194 } 206 }
195 207
208 virtual const char* type() const;
209
196 virtual void SerializeToDict(DictionaryValue *dict) const; 210 virtual void SerializeToDict(DictionaryValue *dict) const;
197 211
198 void SetValue(std::string value, int selection_start, int selection_end) { 212 void SetValue(std::string value, int selection_start, int selection_end) {
199 value_ = value; 213 value_ = value;
200 selection_start_ = selection_start; 214 selection_start_ = selection_start;
201 selection_end_ = selection_end; 215 selection_end_ = selection_end;
202 } 216 }
203 217
204 private: 218 private:
205 std::string value_; 219 std::string value_;
(...skipping 10 matching lines...) Expand all
216 std::string name, 230 std::string name,
217 std::string value, 231 std::string value,
218 int item_index, 232 int item_index,
219 int item_count) 233 int item_count)
220 : AccessibilityControlInfo(profile, name), 234 : AccessibilityControlInfo(profile, name),
221 value_(value), 235 value_(value),
222 item_index_(item_index), 236 item_index_(item_index),
223 item_count_(item_count) { 237 item_count_(item_count) {
224 } 238 }
225 239
240 virtual const char* type() const;
241
226 virtual void SerializeToDict(DictionaryValue *dict) const; 242 virtual void SerializeToDict(DictionaryValue *dict) const;
227 243
228 void SetValue(int item_index, std::string value) { 244 void SetValue(int item_index, std::string value) {
229 item_index_ = item_index; 245 item_index_ = item_index;
230 value_ = value; 246 value_ = value;
231 } 247 }
232 248
233 private: 249 private:
234 std::string value_; 250 std::string value_;
235 // The 0-based index of the current item and the number of total items. 251 // The 0-based index of the current item and the number of total items.
236 // If the value is not one of the drop-down options, |item_index_| should 252 // If the value is not one of the drop-down options, |item_index_| should
237 // be -1. 253 // be -1.
238 int item_index_; 254 int item_index_;
239 int item_count_; 255 int item_count_;
240 }; 256 };
241 257
242 // Accessibility information about a menu; this class is used by 258 // Accessibility information about a menu; this class is used by
243 // onMenuOpened, onMenuClosed, and onControlFocused event listeners. 259 // onMenuOpened, onMenuClosed, and onControlFocused event listeners.
244 class AccessibilityMenuInfo : public AccessibilityControlInfo { 260 class AccessibilityMenuInfo : public AccessibilityControlInfo {
245 public: 261 public:
246 AccessibilityMenuInfo(Profile* profile, std::string menu_name) 262 AccessibilityMenuInfo(Profile* profile, std::string menu_name)
247 : AccessibilityControlInfo(profile, menu_name) { } 263 : AccessibilityControlInfo(profile, menu_name) { }
248 264
249 virtual void SerializeToDict(DictionaryValue *dict) const; 265 virtual const char* type() const;
250 }; 266 };
251 267
252 // Accessibility information about a menu item; this class is used by 268 // Accessibility information about a menu item; this class is used by
253 // onControlFocused event listeners. 269 // onControlFocused event listeners.
254 class AccessibilityMenuItemInfo : public AccessibilityControlInfo { 270 class AccessibilityMenuItemInfo : public AccessibilityControlInfo {
255 public: 271 public:
256 AccessibilityMenuItemInfo(Profile* profile, 272 AccessibilityMenuItemInfo(Profile* profile,
257 std::string name, 273 std::string name,
258 bool has_submenu, 274 bool has_submenu,
259 int item_index, 275 int item_index,
260 int item_count) 276 int item_count)
261 : AccessibilityControlInfo(profile, name), 277 : AccessibilityControlInfo(profile, name),
262 has_submenu_(has_submenu), 278 has_submenu_(has_submenu),
263 item_index_(item_index), 279 item_index_(item_index),
264 item_count_(item_count) { 280 item_count_(item_count) {
265 } 281 }
266 282
283 virtual const char* type() const;
284
267 virtual void SerializeToDict(DictionaryValue *dict) const; 285 virtual void SerializeToDict(DictionaryValue *dict) const;
268 286
269 private: 287 private:
270 bool has_submenu_; 288 bool has_submenu_;
271 // The 0-based index of the current item and the number of total items. 289 // The 0-based index of the current item and the number of total items.
272 int item_index_; 290 int item_index_;
273 int item_count_; 291 int item_count_;
274 }; 292 };
275 293
276 #endif // CHROME_BROWSER_ACCESSIBILITY_EVENTS_H_ 294 #endif // CHROME_BROWSER_ACCESSIBILITY_EVENTS_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/accessibility_events.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698