1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_ACCESSIBILITY_ACCESSIBILITY_EVENTS_H_
#define CHROME_BROWSER_ACCESSIBILITY_ACCESSIBILITY_EVENTS_H_
#include <string>
#include "base/compiler_specific.h"
#include "ui/accessibility/ax_enums.h"
#include "ui/gfx/geometry/rect.h"
class AccessibilityControlInfo;
class AccessibilityMenuInfo;
class AccessibilityWindowInfo;
class Profile;
namespace base {
class DictionaryValue;
}
// Notify the ExtensionAccessibilityEventRouter of the given accessibility
// event and AccessibilityEventInfo details. Will not send if the profile's
// pause level is nonzero (using profile->PauseAccessibilityEvents).
void SendControlAccessibilityNotification(
ui::AXEvent event,
AccessibilityControlInfo* info);
void SendMenuAccessibilityNotification(
ui::AXEvent event,
AccessibilityMenuInfo* info);
void SendWindowAccessibilityNotification(
ui::AXEvent event,
AccessibilityWindowInfo* info);
// Abstract parent class for accessibility event information passed to event
// listeners.
class AccessibilityEventInfo {
public:
virtual ~AccessibilityEventInfo() {}
// Serialize this class as a DictionaryValue that can be converted to
// a JavaScript object.
virtual void SerializeToDict(base::DictionaryValue* dict) const = 0;
Profile* profile() const { return profile_; }
protected:
explicit AccessibilityEventInfo(Profile* profile) : profile_(profile) {}
// The profile this control belongs to.
Profile* profile_;
};
// Abstract parent class for accessibility information about a control
// passed to event listeners.
class AccessibilityControlInfo : public AccessibilityEventInfo {
public:
~AccessibilityControlInfo() override;
// Serialize this class as a DictionaryValue that can be converted to
// a JavaScript object.
void SerializeToDict(base::DictionaryValue* dict) const override;
// Return the specific type of this control, which will be one of the
// string constants defined in extension_accessibility_api_constants.h.
virtual const char* type() const = 0;
const std::string& name() const { return name_; }
const std::string& context() const { return context_; }
void set_bounds(const gfx::Rect& bounds) { bounds_ = bounds; }
const gfx::Rect& bounds() const { return bounds_; }
protected:
AccessibilityControlInfo(Profile* profile,
const std::string& name);
void set_context(const std::string& context) { context_ = context; }
// The name of the control, like "OK" or "Password".
std::string name_;
// A string describing the context of the control, such as the name of
// the group or toolbar it's contained in.
std::string context_;
// The bounds of the control in global screen coordinates.
gfx::Rect bounds_;
};
// Accessibility information about a window passed to onWindowOpened
// and onWindowClosed event listeners.
class AccessibilityWindowInfo : public AccessibilityControlInfo {
public:
AccessibilityWindowInfo(Profile* profile, const std::string& window_name);
const char* type() const override;
};
// Accessibility information about a push button passed to onControlFocused
// and onControlAction event listeners.
class AccessibilityButtonInfo : public AccessibilityControlInfo {
public:
AccessibilityButtonInfo(Profile* profile,
const std::string& button_name,
const std::string& context);
const char* type() const override;
};
// Accessibility information about static text passed to onControlFocused
// and onControlAction event listeners.
class AccessibilityStaticTextInfo : public AccessibilityControlInfo {
public:
AccessibilityStaticTextInfo(Profile* profile,
const std::string& text,
const std::string& context);
const char* type() const override;
};
// Accessibility information about a hyperlink passed to onControlFocused
// and onControlAction event listeners.
class AccessibilityLinkInfo : public AccessibilityControlInfo {
public:
AccessibilityLinkInfo(Profile* profile,
const std::string& link_name,
const std::string& context);
const char* type() const override;
};
// Accessibility information about a radio button passed to onControlFocused
// and onControlAction event listeners.
class AccessibilityRadioButtonInfo : public AccessibilityControlInfo {
public:
AccessibilityRadioButtonInfo(Profile* profile,
const std::string& name,
const std::string& context,
bool checked,
int item_index,
int item_count);
const char* type() const override;
void SerializeToDict(base::DictionaryValue* dict) const override;
void SetChecked(bool checked) { checked_ = checked; }
int item_index() const { return item_index_; }
int item_count() const { return item_count_; }
bool checked() const { return checked_; }
private:
bool checked_;
// The 0-based index of this radio button and number of buttons in the group.
int item_index_;
int item_count_;
};
// Accessibility information about a checkbox passed to onControlFocused
// and onControlAction event listeners.
class AccessibilityCheckboxInfo : public AccessibilityControlInfo {
public:
AccessibilityCheckboxInfo(Profile* profile,
const std::string& name,
const std::string& context,
bool checked);
const char* type() const override;
void SerializeToDict(base::DictionaryValue* dict) const override;
void SetChecked(bool checked) { checked_ = checked; }
bool checked() const { return checked_; }
private:
bool checked_;
};
// Accessibility information about a tab passed to onControlFocused
// and onControlAction event listeners.
class AccessibilityTabInfo : public AccessibilityControlInfo {
public:
AccessibilityTabInfo(Profile* profile,
const std::string& tab_name,
const std::string& context,
int tab_index,
int tab_count);
const char* type() const override;
void SerializeToDict(base::DictionaryValue* dict) const override;
void SetTab(int tab_index, std::string tab_name) {
tab_index_ = tab_index;
name_ = tab_name;
}
int tab_index() const { return tab_index_; }
int tab_count() const { return tab_count_; }
private:
// The 0-based index of this tab and number of tabs in the group.
int tab_index_;
int tab_count_;
};
// Accessibility information about a combo box passed to onControlFocused
// and onControlAction event listeners.
class AccessibilityComboBoxInfo : public AccessibilityControlInfo {
public:
AccessibilityComboBoxInfo(Profile* profile,
const std::string& name,
const std::string& context,
const std::string& value,
int item_index,
int item_count);
const char* type() const override;
void SerializeToDict(base::DictionaryValue* dict) const override;
void SetValue(int item_index, const std::string& value) {
item_index_ = item_index;
value_ = value;
}
int item_index() const { return item_index_; }
int item_count() const { return item_count_; }
const std::string& value() const { return value_; }
private:
std::string value_;
// The 0-based index of the current item and the number of total items.
// If the value is not one of the drop-down options, |item_index_| should
// be -1.
int item_index_;
int item_count_;
};
// Accessibility information about a text box, passed to onControlFocused,
// onControlAction, and onTextChanged event listeners.
class AccessibilityTextBoxInfo : public AccessibilityControlInfo {
public:
AccessibilityTextBoxInfo(Profile* profile,
const std::string& name,
const std::string& context,
bool password);
const char* type() const override;
void SerializeToDict(base::DictionaryValue* dict) const override;
void SetValue(
const std::string& value, int selection_start, int selection_end) {
value_ = value;
selection_start_ = selection_start;
selection_end_ = selection_end;
}
const std::string& value() const { return value_; }
bool password() const { return password_; }
int selection_start() const { return selection_start_; }
int selection_end() const { return selection_end_; }
private:
std::string value_;
bool password_;
int selection_start_;
int selection_end_;
};
// Accessibility information about a combo box passed to onControlFocused
// and onControlAction event listeners.
class AccessibilityListBoxInfo : public AccessibilityControlInfo {
public:
AccessibilityListBoxInfo(Profile* profile,
const std::string& name,
const std::string& context,
const std::string& value,
int item_index,
int item_count);
const char* type() const override;
void SerializeToDict(base::DictionaryValue* dict) const override;
void SetValue(int item_index, std::string value) {
item_index_ = item_index;
value_ = value;
}
int item_index() const { return item_index_; }
int item_count() const { return item_count_; }
const std::string& value() const { return value_; }
private:
std::string value_;
// The 0-based index of the current item and the number of total items.
// If the value is not one of the drop-down options, |item_index_| should
// be -1.
int item_index_;
int item_count_;
};
// Accessibility information about a menu; this class is used by
// onMenuOpened, onMenuClosed, and onControlFocused event listeners.
class AccessibilityMenuInfo : public AccessibilityControlInfo {
public:
AccessibilityMenuInfo(Profile* profile, const std::string& menu_name);
const char* type() const override;
};
// Accessibility information about a menu item; this class is used by
// onControlFocused event listeners.
class AccessibilityMenuItemInfo : public AccessibilityControlInfo {
public:
AccessibilityMenuItemInfo(Profile* profile,
const std::string& name,
const std::string& context,
bool has_submenu,
int item_index,
int item_count);
const char* type() const override;
void SerializeToDict(base::DictionaryValue* dict) const override;
int item_index() const { return item_index_; }
int item_count() const { return item_count_; }
bool has_submenu() const { return has_submenu_; }
private:
bool has_submenu_;
// The 0-based index of the current item and the number of total items.
int item_index_;
int item_count_;
};
// Accessibility information about a tree; this class is used by
// onControlFocused event listeners.
class AccessibilityTreeInfo : public AccessibilityControlInfo {
public:
AccessibilityTreeInfo(Profile* profile, const std::string& menu_name);
const char* type() const override;
};
// Accessibility information about a tree item; this class is used by
// onControlFocused event listeners.
class AccessibilityTreeItemInfo : public AccessibilityControlInfo {
public:
AccessibilityTreeItemInfo(Profile* profile,
const std::string& name,
const std::string& context,
int item_depth,
int item_index,
int item_count,
int children_count,
bool is_expanded);
const char* type() const override;
void SerializeToDict(base::DictionaryValue* dict) const override;
int item_depth() const { return item_depth_; }
int item_index() const { return item_index_; }
int item_count() const { return item_count_; }
int children_count() const { return children_count_; }
bool is_expanded() const { return is_expanded_; }
private:
// 0-based item depth.
int item_depth_;
// The 0-based index of the current item and the number of total items at the
// current depth.
int item_index_;
// Count of items at the current depth.
int item_count_;
// Count of children of the current item.
int children_count_;
// True if the node is expanded.
bool is_expanded_;
};
// Accessibility information about a slider passed to onControlFocused
// and onControlAction event listeners.
class AccessibilitySliderInfo : public AccessibilityControlInfo {
public:
AccessibilitySliderInfo(Profile* profile,
const std::string& name,
const std::string& context,
const std::string& value);
const char* type() const override;
void SerializeToDict(base::DictionaryValue* dict) const override;
const std::string& value() const { return value_; }
private:
std::string value_;
};
// Accessibility information about an alert passed to onControlAction event.
class AccessibilityAlertInfo : public AccessibilityControlInfo {
public:
AccessibilityAlertInfo(Profile* profile, const std::string& name);
const char* type() const override;
};
// Accessibility information about a table; this class is used by
// onControlFocused event listeners.
class AccessibilityTableInfo : public AccessibilityControlInfo {
public:
AccessibilityTableInfo(Profile* profile, const std::string& menu_name);
const char* type() const override;
};
// Accessibility information about a table row; this class is used by
// onControlFocused event listeners.
class AccessibilityRowInfo : public AccessibilityControlInfo {
public:
AccessibilityRowInfo(Profile* profile,
const std::string& name,
const std::string& context,
int item_index,
int item_count);
const char* type() const override;
int item_index() const { return item_index_; }
int item_count() const { return item_count_; }
private:
// The 0-based index of the currently selected row.
int item_index_;
// Count of rows in the table.
int item_count_;
};
#endif // CHROME_BROWSER_ACCESSIBILITY_ACCESSIBILITY_EVENTS_H_
|