summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/accessibility_events.cc56
-rw-r--r--chrome/browser/accessibility_events.h26
2 files changed, 59 insertions, 23 deletions
diff --git a/chrome/browser/accessibility_events.cc b/chrome/browser/accessibility_events.cc
index 79d2af9..068a3b4 100644
--- a/chrome/browser/accessibility_events.cc
+++ b/chrome/browser/accessibility_events.cc
@@ -24,78 +24,96 @@ void SendAccessibilityNotification(
void AccessibilityControlInfo::SerializeToDict(DictionaryValue *dict) const {
dict->SetString(keys::kNameKey, name_);
+ dict->SetString(keys::kTypeKey, type());
}
-void AccessibilityWindowInfo::SerializeToDict(DictionaryValue *dict) const {
- AccessibilityControlInfo::SerializeToDict(dict);
- dict->SetString(keys::kTypeKey, keys::kTypeWindow);
+const char* AccessibilityWindowInfo::type() const {
+ return keys::kTypeWindow;
}
-void AccessibilityButtonInfo::SerializeToDict(DictionaryValue *dict) const {
- AccessibilityControlInfo::SerializeToDict(dict);
- dict->SetString(keys::kTypeKey, keys::kTypeButton);
+const char* AccessibilityButtonInfo::type() const {
+ return keys::kTypeButton;
}
-void AccessibilityLinkInfo::SerializeToDict(DictionaryValue *dict) const {
- AccessibilityControlInfo::SerializeToDict(dict);
- dict->SetString(keys::kTypeKey, keys::kTypeLink);
+const char* AccessibilityLinkInfo::type() const {
+ return keys::kTypeLink;
+}
+
+const char* AccessibilityRadioButtonInfo::type() const {
+ return keys::kTypeRadioButton;
}
void AccessibilityRadioButtonInfo::SerializeToDict(
DictionaryValue *dict) const {
AccessibilityControlInfo::SerializeToDict(dict);
- dict->SetString(keys::kTypeKey, keys::kTypeRadioButton);
dict->SetBoolean(keys::kCheckedKey, checked_);
dict->SetInteger(keys::kItemIndexKey, item_index_);
dict->SetInteger(keys::kItemCountKey, item_count_);
}
+const char* AccessibilityCheckboxInfo::type() const {
+ return keys::kTypeCheckbox;
+}
+
void AccessibilityCheckboxInfo::SerializeToDict(DictionaryValue *dict) const {
AccessibilityControlInfo::SerializeToDict(dict);
- dict->SetString(keys::kTypeKey, keys::kTypeCheckbox);
dict->SetBoolean(keys::kCheckedKey, checked_);
}
+const char* AccessibilityTabInfo::type() const {
+ return keys::kTypeTab;
+}
+
void AccessibilityTabInfo::SerializeToDict(DictionaryValue *dict) const {
AccessibilityControlInfo::SerializeToDict(dict);
- dict->SetString(keys::kTypeKey, keys::kTypeTab);
dict->SetInteger(keys::kItemIndexKey, tab_index_);
dict->SetInteger(keys::kItemCountKey, tab_count_);
}
+const char* AccessibilityComboBoxInfo::type() const {
+ return keys::kTypeComboBox;
+}
+
void AccessibilityComboBoxInfo::SerializeToDict(DictionaryValue *dict) const {
AccessibilityControlInfo::SerializeToDict(dict);
- dict->SetString(keys::kTypeKey, keys::kTypeComboBox);
dict->SetString(keys::kValueKey, value_);
dict->SetInteger(keys::kItemIndexKey, item_index_);
dict->SetInteger(keys::kItemCountKey, item_count_);
}
+const char* AccessibilityTextBoxInfo::type() const {
+ return keys::kTypeTextBox;
+}
+
void AccessibilityTextBoxInfo::SerializeToDict(DictionaryValue *dict) const {
AccessibilityControlInfo::SerializeToDict(dict);
- dict->SetString(keys::kTypeKey, keys::kTypeTextBox);
dict->SetString(keys::kValueKey, value_);
dict->SetBoolean(keys::kPasswordKey, password_);
dict->SetInteger(keys::kSelectionStartKey, selection_start_);
dict->SetInteger(keys::kSelectionEndKey, selection_end_);
}
+const char* AccessibilityListBoxInfo::type() const {
+ return keys::kTypeListBox;
+}
+
void AccessibilityListBoxInfo::SerializeToDict(DictionaryValue *dict) const {
AccessibilityControlInfo::SerializeToDict(dict);
- dict->SetString(keys::kTypeKey, keys::kTypeListBox);
dict->SetString(keys::kValueKey, value_);
dict->SetInteger(keys::kItemIndexKey, item_index_);
dict->SetInteger(keys::kItemCountKey, item_count_);
}
-void AccessibilityMenuInfo::SerializeToDict(DictionaryValue *dict) const {
- AccessibilityControlInfo::SerializeToDict(dict);
- dict->SetString(keys::kTypeKey, keys::kTypeMenu);
+const char* AccessibilityMenuInfo::type() const {
+ return keys::kTypeMenu;
+}
+
+const char* AccessibilityMenuItemInfo::type() const {
+ return keys::kTypeMenuItem;
}
void AccessibilityMenuItemInfo::SerializeToDict(DictionaryValue *dict) const {
AccessibilityControlInfo::SerializeToDict(dict);
- dict->SetString(keys::kTypeKey, keys::kTypeMenuItem);
dict->SetBoolean(keys::kHasSubmenuKey, has_submenu_);
dict->SetInteger(keys::kItemIndexKey, item_index_);
dict->SetInteger(keys::kItemCountKey, item_count_);
diff --git a/chrome/browser/accessibility_events.h b/chrome/browser/accessibility_events.h
index 33f44a4..29376cd 100644
--- a/chrome/browser/accessibility_events.h
+++ b/chrome/browser/accessibility_events.h
@@ -31,6 +31,10 @@ class AccessibilityControlInfo {
// a JavaScript object.
virtual void SerializeToDict(DictionaryValue *dict) const;
+ // 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;
+
Profile* profile() const { return profile_; }
const std::string& name() const { return name_; }
@@ -54,7 +58,7 @@ class AccessibilityWindowInfo : public AccessibilityControlInfo {
AccessibilityWindowInfo(Profile* profile, std::string window_name)
: AccessibilityControlInfo(profile, window_name) { }
- virtual void SerializeToDict(DictionaryValue *dict) const;
+ virtual const char* type() const;
};
// Accessibility information about a push button passed to onControlFocused
@@ -64,7 +68,7 @@ class AccessibilityButtonInfo : public AccessibilityControlInfo {
AccessibilityButtonInfo(Profile* profile, std::string button_name)
: AccessibilityControlInfo(profile, button_name) { }
- virtual void SerializeToDict(DictionaryValue *dict) const;
+ virtual const char* type() const;
};
// Accessibility information about a hyperlink passed to onControlFocused
@@ -74,7 +78,7 @@ class AccessibilityLinkInfo : public AccessibilityControlInfo {
AccessibilityLinkInfo(Profile* profile, std::string link_name)
: AccessibilityControlInfo(profile, link_name) { }
- virtual void SerializeToDict(DictionaryValue *dict) const;
+ virtual const char* type() const;
};
// Accessibility information about a radio button passed to onControlFocused
@@ -92,6 +96,8 @@ class AccessibilityRadioButtonInfo : public AccessibilityControlInfo {
item_count_(item_count) {
}
+ virtual const char* type() const;
+
virtual void SerializeToDict(DictionaryValue *dict) const;
void SetChecked(bool checked) { checked_ = checked; }
@@ -114,6 +120,8 @@ class AccessibilityCheckboxInfo : public AccessibilityControlInfo {
checked_(checked) {
}
+ virtual const char* type() const;
+
virtual void SerializeToDict(DictionaryValue *dict) const;
void SetChecked(bool checked) { checked_ = checked; }
@@ -135,6 +143,8 @@ class AccessibilityTabInfo : public AccessibilityControlInfo {
tab_count_(tab_count) {
}
+ virtual const char* type() const;
+
virtual void SerializeToDict(DictionaryValue *dict) const;
void SetTab(int tab_index, std::string tab_name) {
@@ -163,6 +173,8 @@ class AccessibilityComboBoxInfo : public AccessibilityControlInfo {
item_count_(item_count) {
}
+ virtual const char* type() const;
+
virtual void SerializeToDict(DictionaryValue *dict) const;
void SetValue(int item_index, std::string value) {
@@ -193,6 +205,8 @@ class AccessibilityTextBoxInfo : public AccessibilityControlInfo {
selection_end_(0) {
}
+ virtual const char* type() const;
+
virtual void SerializeToDict(DictionaryValue *dict) const;
void SetValue(std::string value, int selection_start, int selection_end) {
@@ -223,6 +237,8 @@ class AccessibilityListBoxInfo : public AccessibilityControlInfo {
item_count_(item_count) {
}
+ virtual const char* type() const;
+
virtual void SerializeToDict(DictionaryValue *dict) const;
void SetValue(int item_index, std::string value) {
@@ -246,7 +262,7 @@ class AccessibilityMenuInfo : public AccessibilityControlInfo {
AccessibilityMenuInfo(Profile* profile, std::string menu_name)
: AccessibilityControlInfo(profile, menu_name) { }
- virtual void SerializeToDict(DictionaryValue *dict) const;
+ virtual const char* type() const;
};
// Accessibility information about a menu item; this class is used by
@@ -264,6 +280,8 @@ class AccessibilityMenuItemInfo : public AccessibilityControlInfo {
item_count_(item_count) {
}
+ virtual const char* type() const;
+
virtual void SerializeToDict(DictionaryValue *dict) const;
private: