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

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

Issue 402099: Add an accessibility API for events raised outside of the web content. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 10 years, 10 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 | « chrome/chrome_common.gypi ('k') | chrome/common/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')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_COMMON_ACCESSIBILITY_EVENTS_H_
6 #define CHROME_COMMON_ACCESSIBILITY_EVENTS_H_
7
8 #include <string>
9
10 #include "base/values.h"
11
12 class AccessibilityControlInfo;
13 class NotificationType;
14 class Profile;
15
16 // Use the NotificationService to post the given accessibility
17 // notification type with AccessibilityControlInfo details to any
18 // listeners. Will not send if the profile's pause level is nonzero
19 // (using profile->PauseAccessibilityEvents).
20 void SendAccessibilityNotification(
21 NotificationType type, AccessibilityControlInfo* info);
22
23 // Abstract parent class for accessibility information about a control
24 // passed to event listeners.
25 class AccessibilityControlInfo {
26 public:
27 virtual ~AccessibilityControlInfo() { }
28
29 // Serialize this class as a DictionaryValue that can be converted to
30 // a JavaScript object.
31 virtual void SerializeToDict(DictionaryValue *dict) const;
32
33 Profile* profile() const { return profile_; }
34
35 const std::string& name() const { return name_; }
36
37 protected:
38 // The constructor can only be called by subclasses.
39 AccessibilityControlInfo(Profile* profile, std::string control_name)
40 : profile_(profile), name_(control_name) { }
41
42 // The profile this control belongs to.
43 Profile* profile_;
44
45 // The name of the control, like "OK" or "Password".
46 std::string name_;
47 };
48
49 // Accessibility information about a window passed to onWindowOpened
50 // and onWindowClosed event listeners.
51 class AccessibilityWindowInfo : public AccessibilityControlInfo {
52 public:
53 AccessibilityWindowInfo(Profile* profile, std::string window_name)
54 : AccessibilityControlInfo(profile, window_name) { }
55
56 virtual void SerializeToDict(DictionaryValue *dict) const;
57 };
58
59 // Accessibility information about a push button passed to onControlFocused
60 // and onControlAction event listeners.
61 class AccessibilityButtonInfo : public AccessibilityControlInfo {
62 public:
63 AccessibilityButtonInfo(Profile* profile, std::string button_name)
64 : AccessibilityControlInfo(profile, button_name) { }
65
66 virtual void SerializeToDict(DictionaryValue *dict) const;
67 };
68
69 // Accessibility information about a hyperlink passed to onControlFocused
70 // and onControlAction event listeners.
71 class AccessibilityLinkInfo : public AccessibilityControlInfo {
72 public:
73 AccessibilityLinkInfo(Profile* profile, std::string link_name)
74 : AccessibilityControlInfo(profile, link_name) { }
75
76 virtual void SerializeToDict(DictionaryValue *dict) const;
77 };
78
79 // Accessibility information about a radio button passed to onControlFocused
80 // and onControlAction event listeners.
81 class AccessibilityRadioButtonInfo : public AccessibilityControlInfo {
82 public:
83 AccessibilityRadioButtonInfo(Profile* profile,
84 std::string name,
85 bool checked,
86 int item_index,
87 int item_count)
88 : AccessibilityControlInfo(profile, name),
89 checked_(checked),
90 item_index_(item_index),
91 item_count_(item_count) { }
92
93 virtual void SerializeToDict(DictionaryValue *dict) const;
94
95 void SetChecked(bool checked) { checked_ = checked; }
96
97 private:
98 bool checked_;
99 // The 0-based index of this radio button and number of buttons in the group.
100 int item_index_;
101 int item_count_;
102 };
103
104 // Accessibility information about a checkbox passed to onControlFocused
105 // and onControlAction event listeners.
106 class AccessibilityCheckboxInfo : public AccessibilityControlInfo {
107 public:
108 AccessibilityCheckboxInfo(Profile* profile,
109 std::string name,
110 bool checked)
111 : AccessibilityControlInfo(profile, name),
112 checked_(checked) { }
113
114 virtual void SerializeToDict(DictionaryValue *dict) const;
115
116 void SetChecked(bool checked) { checked_ = checked; }
117
118 private:
119 bool checked_;
120 };
121
122 // Accessibility information about a tab passed to onControlFocused
123 // and onControlAction event listeners.
124 class AccessibilityTabInfo : public AccessibilityControlInfo {
125 public:
126 AccessibilityTabInfo(Profile* profile,
127 std::string tab_name,
128 int tab_index,
129 int tab_count)
130 : AccessibilityControlInfo(profile, tab_name),
131 tab_index_(tab_index),
132 tab_count_(tab_count) { }
133
134 virtual void SerializeToDict(DictionaryValue *dict) const;
135
136 void SetTab(int tab_index, std::string tab_name) {
137 tab_index_ = tab_index;
138 name_ = tab_name;
139 }
140
141 private:
142 // The 0-based index of this tab and number of tabs in the group.
143 int tab_index_;
144 int tab_count_;
145 };
146
147 // Accessibility information about a combo box passed to onControlFocused
148 // and onControlAction event listeners.
149 class AccessibilityComboBoxInfo : public AccessibilityControlInfo {
150 public:
151 AccessibilityComboBoxInfo(Profile* profile,
152 std::string name,
153 std::string value,
154 int item_index,
155 int item_count)
156 : AccessibilityControlInfo(profile, name),
157 value_(value),
158 item_index_(item_index),
159 item_count_(item_count) { }
160
161 virtual void SerializeToDict(DictionaryValue *dict) const;
162
163 void SetValue(int item_index, std::string value) {
164 item_index_ = item_index;
165 value_ = value;
166 }
167
168 private:
169 std::string value_;
170 // The 0-based index of the current item and the number of total items.
171 // If the value is not one of the drop-down options, item_index_ should
172 // be -1.
173 int item_index_;
174 int item_count_;
175 };
176
177 // Accessibility information about a text box, passed to onControlFocused,
178 // onControlAction, and onTextChanged event listeners.
179 class AccessibilityTextBoxInfo : public AccessibilityControlInfo {
180 public:
181 AccessibilityTextBoxInfo(Profile* profile,
182 std::string name,
183 bool password)
184 : AccessibilityControlInfo(profile, name),
185 value_(""),
186 password_(password),
187 selection_start_(0),
188 selection_end_(0) { }
189
190 virtual void SerializeToDict(DictionaryValue *dict) const;
191
192 void SetValue(std::string value, int selection_start, int selection_end) {
193 value_ = value;
194 selection_start_ = selection_start;
195 selection_end_ = selection_end;
196 }
197
198 private:
199 std::string value_;
200 bool password_;
201 int selection_start_;
202 int selection_end_;
203 };
204
205 #endif // CHROME_COMMON_ACCESSIBILITY_EVENTS_H_
OLDNEW
« no previous file with comments | « chrome/chrome_common.gypi ('k') | chrome/common/accessibility_events.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698