| OLD | NEW |
| 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 #include "chrome/browser/accessibility/accessibility_events.h" | 5 #include "chrome/browser/accessibility/accessibility_events.h" |
| 6 | 6 |
| 7 #include "base/values.h" | 7 #include "base/values.h" |
| 8 | 8 |
| 9 #include "chrome/browser/accessibility/accessibility_extension_api_constants.h" | 9 #include "chrome/browser/accessibility/accessibility_extension_api_constants.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 } | 26 } |
| 27 | 27 |
| 28 void SendAccessibilityVolumeNotification(double volume, bool is_muted) { | 28 void SendAccessibilityVolumeNotification(double volume, bool is_muted) { |
| 29 Profile* profile = ProfileManager::GetDefaultProfile(); | 29 Profile* profile = ProfileManager::GetDefaultProfile(); |
| 30 AccessibilityVolumeInfo info(profile, volume, is_muted); | 30 AccessibilityVolumeInfo info(profile, volume, is_muted); |
| 31 SendAccessibilityNotification( | 31 SendAccessibilityNotification( |
| 32 chrome::NOTIFICATION_ACCESSIBILITY_VOLUME_CHANGED, &info); | 32 chrome::NOTIFICATION_ACCESSIBILITY_VOLUME_CHANGED, &info); |
| 33 } | 33 } |
| 34 | 34 |
| 35 AccessibilityControlInfo::AccessibilityControlInfo( | 35 AccessibilityControlInfo::AccessibilityControlInfo( |
| 36 Profile* profile, const std::string& control_name) | 36 Profile* profile, const std::string& name) |
| 37 : AccessibilityEventInfo(profile), name_(control_name) { | 37 : AccessibilityEventInfo(profile), |
| 38 name_(name) { |
| 38 } | 39 } |
| 39 | 40 |
| 40 AccessibilityControlInfo::~AccessibilityControlInfo() { | 41 AccessibilityControlInfo::~AccessibilityControlInfo() { |
| 41 } | 42 } |
| 42 | 43 |
| 43 void AccessibilityControlInfo::SerializeToDict(DictionaryValue *dict) const { | 44 void AccessibilityControlInfo::SerializeToDict(DictionaryValue *dict) const { |
| 44 dict->SetString(keys::kNameKey, name_); | 45 dict->SetString(keys::kNameKey, name_); |
| 45 dict->SetString(keys::kTypeKey, type()); | 46 dict->SetString(keys::kTypeKey, type()); |
| 47 if (!context_.empty()) |
| 48 dict->SetString(keys::kContextKey, context_); |
| 46 } | 49 } |
| 47 | 50 |
| 48 AccessibilityWindowInfo::AccessibilityWindowInfo(Profile* profile, | 51 AccessibilityWindowInfo::AccessibilityWindowInfo(Profile* profile, |
| 49 const std::string& window_name) | 52 const std::string& window_name) |
| 50 : AccessibilityControlInfo(profile, window_name) { | 53 : AccessibilityControlInfo(profile, window_name) { |
| 51 } | 54 } |
| 52 | 55 |
| 53 const char* AccessibilityWindowInfo::type() const { | 56 const char* AccessibilityWindowInfo::type() const { |
| 54 return keys::kTypeWindow; | 57 return keys::kTypeWindow; |
| 55 } | 58 } |
| 56 | 59 |
| 57 AccessibilityButtonInfo::AccessibilityButtonInfo(Profile* profile, | 60 AccessibilityButtonInfo::AccessibilityButtonInfo(Profile* profile, |
| 58 const std::string& button_name) | 61 const std::string& button_name, |
| 62 const std::string& context) |
| 59 : AccessibilityControlInfo(profile, button_name) { | 63 : AccessibilityControlInfo(profile, button_name) { |
| 64 set_context(context); |
| 60 } | 65 } |
| 61 | 66 |
| 62 const char* AccessibilityButtonInfo::type() const { | 67 const char* AccessibilityButtonInfo::type() const { |
| 63 return keys::kTypeButton; | 68 return keys::kTypeButton; |
| 64 } | 69 } |
| 65 | 70 |
| 66 AccessibilityLinkInfo::AccessibilityLinkInfo(Profile* profile, | 71 AccessibilityLinkInfo::AccessibilityLinkInfo(Profile* profile, |
| 67 const std::string& link_name) | 72 const std::string& link_name, |
| 68 : AccessibilityControlInfo(profile, link_name) { } | 73 const std::string& context) |
| 74 : AccessibilityControlInfo(profile, link_name) { |
| 75 set_context(context); |
| 76 } |
| 69 | 77 |
| 70 const char* AccessibilityLinkInfo::type() const { | 78 const char* AccessibilityLinkInfo::type() const { |
| 71 return keys::kTypeLink; | 79 return keys::kTypeLink; |
| 72 } | 80 } |
| 73 | 81 |
| 74 AccessibilityRadioButtonInfo::AccessibilityRadioButtonInfo( | 82 AccessibilityRadioButtonInfo::AccessibilityRadioButtonInfo( |
| 75 Profile* profile, | 83 Profile* profile, |
| 76 const std::string& name, | 84 const std::string& name, |
| 85 const std::string& context, |
| 77 bool checked, | 86 bool checked, |
| 78 int item_index, | 87 int item_index, |
| 79 int item_count) | 88 int item_count) |
| 80 : AccessibilityControlInfo(profile, name), | 89 : AccessibilityControlInfo(profile, name), |
| 81 checked_(checked), | 90 checked_(checked), |
| 82 item_index_(item_index), | 91 item_index_(item_index), |
| 83 item_count_(item_count) { | 92 item_count_(item_count) { |
| 93 set_context(context); |
| 84 } | 94 } |
| 85 | 95 |
| 86 const char* AccessibilityRadioButtonInfo::type() const { | 96 const char* AccessibilityRadioButtonInfo::type() const { |
| 87 return keys::kTypeRadioButton; | 97 return keys::kTypeRadioButton; |
| 88 } | 98 } |
| 89 | 99 |
| 90 void AccessibilityRadioButtonInfo::SerializeToDict( | 100 void AccessibilityRadioButtonInfo::SerializeToDict( |
| 91 DictionaryValue *dict) const { | 101 DictionaryValue *dict) const { |
| 92 AccessibilityControlInfo::SerializeToDict(dict); | 102 AccessibilityControlInfo::SerializeToDict(dict); |
| 93 dict->SetBoolean(keys::kCheckedKey, checked_); | 103 dict->SetBoolean(keys::kCheckedKey, checked_); |
| 94 dict->SetInteger(keys::kItemIndexKey, item_index_); | 104 dict->SetInteger(keys::kItemIndexKey, item_index_); |
| 95 dict->SetInteger(keys::kItemCountKey, item_count_); | 105 dict->SetInteger(keys::kItemCountKey, item_count_); |
| 96 } | 106 } |
| 97 | 107 |
| 98 AccessibilityCheckboxInfo::AccessibilityCheckboxInfo(Profile* profile, | 108 AccessibilityCheckboxInfo::AccessibilityCheckboxInfo(Profile* profile, |
| 99 const std::string& name, | 109 const std::string& name, |
| 110 const std::string& context, |
| 100 bool checked) | 111 bool checked) |
| 101 : AccessibilityControlInfo(profile, name), | 112 : AccessibilityControlInfo(profile, name), |
| 102 checked_(checked) { | 113 checked_(checked) { |
| 114 set_context(context); |
| 103 } | 115 } |
| 104 | 116 |
| 105 const char* AccessibilityCheckboxInfo::type() const { | 117 const char* AccessibilityCheckboxInfo::type() const { |
| 106 return keys::kTypeCheckbox; | 118 return keys::kTypeCheckbox; |
| 107 } | 119 } |
| 108 | 120 |
| 109 void AccessibilityCheckboxInfo::SerializeToDict(DictionaryValue *dict) const { | 121 void AccessibilityCheckboxInfo::SerializeToDict(DictionaryValue *dict) const { |
| 110 AccessibilityControlInfo::SerializeToDict(dict); | 122 AccessibilityControlInfo::SerializeToDict(dict); |
| 111 dict->SetBoolean(keys::kCheckedKey, checked_); | 123 dict->SetBoolean(keys::kCheckedKey, checked_); |
| 112 } | 124 } |
| 113 | 125 |
| 114 AccessibilityTabInfo::AccessibilityTabInfo(Profile* profile, | 126 AccessibilityTabInfo::AccessibilityTabInfo(Profile* profile, |
| 115 const std::string& tab_name, | 127 const std::string& tab_name, |
| 128 const std::string& context, |
| 116 int tab_index, | 129 int tab_index, |
| 117 int tab_count) | 130 int tab_count) |
| 118 : AccessibilityControlInfo(profile, tab_name), | 131 : AccessibilityControlInfo(profile, tab_name), |
| 119 tab_index_(tab_index), | 132 tab_index_(tab_index), |
| 120 tab_count_(tab_count) { | 133 tab_count_(tab_count) { |
| 134 set_context(context); |
| 121 } | 135 } |
| 122 | 136 |
| 123 const char* AccessibilityTabInfo::type() const { | 137 const char* AccessibilityTabInfo::type() const { |
| 124 return keys::kTypeTab; | 138 return keys::kTypeTab; |
| 125 } | 139 } |
| 126 | 140 |
| 127 void AccessibilityTabInfo::SerializeToDict(DictionaryValue *dict) const { | 141 void AccessibilityTabInfo::SerializeToDict(DictionaryValue *dict) const { |
| 128 AccessibilityControlInfo::SerializeToDict(dict); | 142 AccessibilityControlInfo::SerializeToDict(dict); |
| 129 dict->SetInteger(keys::kItemIndexKey, tab_index_); | 143 dict->SetInteger(keys::kItemIndexKey, tab_index_); |
| 130 dict->SetInteger(keys::kItemCountKey, tab_count_); | 144 dict->SetInteger(keys::kItemCountKey, tab_count_); |
| 131 } | 145 } |
| 132 | 146 |
| 133 AccessibilityComboBoxInfo::AccessibilityComboBoxInfo(Profile* profile, | 147 AccessibilityComboBoxInfo::AccessibilityComboBoxInfo(Profile* profile, |
| 134 const std::string& name, | 148 const std::string& name, |
| 149 const std::string& context, |
| 135 const std::string& value, | 150 const std::string& value, |
| 136 int item_index, | 151 int item_index, |
| 137 int item_count) | 152 int item_count) |
| 138 : AccessibilityControlInfo(profile, name), | 153 : AccessibilityControlInfo(profile, name), |
| 139 value_(value), | 154 value_(value), |
| 140 item_index_(item_index), | 155 item_index_(item_index), |
| 141 item_count_(item_count) { | 156 item_count_(item_count) { |
| 157 set_context(context); |
| 142 } | 158 } |
| 143 | 159 |
| 144 const char* AccessibilityComboBoxInfo::type() const { | 160 const char* AccessibilityComboBoxInfo::type() const { |
| 145 return keys::kTypeComboBox; | 161 return keys::kTypeComboBox; |
| 146 } | 162 } |
| 147 | 163 |
| 148 void AccessibilityComboBoxInfo::SerializeToDict(DictionaryValue *dict) const { | 164 void AccessibilityComboBoxInfo::SerializeToDict(DictionaryValue *dict) const { |
| 149 AccessibilityControlInfo::SerializeToDict(dict); | 165 AccessibilityControlInfo::SerializeToDict(dict); |
| 150 dict->SetString(keys::kValueKey, value_); | 166 dict->SetString(keys::kValueKey, value_); |
| 151 dict->SetInteger(keys::kItemIndexKey, item_index_); | 167 dict->SetInteger(keys::kItemIndexKey, item_index_); |
| 152 dict->SetInteger(keys::kItemCountKey, item_count_); | 168 dict->SetInteger(keys::kItemCountKey, item_count_); |
| 153 } | 169 } |
| 154 | 170 |
| 155 AccessibilityTextBoxInfo::AccessibilityTextBoxInfo(Profile* profile, | 171 AccessibilityTextBoxInfo::AccessibilityTextBoxInfo(Profile* profile, |
| 156 const std::string& name, | 172 const std::string& name, |
| 173 const std::string& context, |
| 157 bool password) | 174 bool password) |
| 158 : AccessibilityControlInfo(profile, name), | 175 : AccessibilityControlInfo(profile, name), |
| 159 value_(""), | 176 value_(""), |
| 160 password_(password), | 177 password_(password), |
| 161 selection_start_(0), | 178 selection_start_(0), |
| 162 selection_end_(0) { | 179 selection_end_(0) { |
| 180 set_context(context); |
| 163 } | 181 } |
| 164 | 182 |
| 165 const char* AccessibilityTextBoxInfo::type() const { | 183 const char* AccessibilityTextBoxInfo::type() const { |
| 166 return keys::kTypeTextBox; | 184 return keys::kTypeTextBox; |
| 167 } | 185 } |
| 168 | 186 |
| 169 void AccessibilityTextBoxInfo::SerializeToDict(DictionaryValue *dict) const { | 187 void AccessibilityTextBoxInfo::SerializeToDict(DictionaryValue *dict) const { |
| 170 AccessibilityControlInfo::SerializeToDict(dict); | 188 AccessibilityControlInfo::SerializeToDict(dict); |
| 171 dict->SetString(keys::kValueKey, value_); | 189 dict->SetString(keys::kValueKey, value_); |
| 172 dict->SetBoolean(keys::kPasswordKey, password_); | 190 dict->SetBoolean(keys::kPasswordKey, password_); |
| 173 dict->SetInteger(keys::kSelectionStartKey, selection_start_); | 191 dict->SetInteger(keys::kSelectionStartKey, selection_start_); |
| 174 dict->SetInteger(keys::kSelectionEndKey, selection_end_); | 192 dict->SetInteger(keys::kSelectionEndKey, selection_end_); |
| 175 } | 193 } |
| 176 | 194 |
| 177 AccessibilityListBoxInfo::AccessibilityListBoxInfo(Profile* profile, | 195 AccessibilityListBoxInfo::AccessibilityListBoxInfo(Profile* profile, |
| 178 const std::string& name, | 196 const std::string& name, |
| 197 const std::string& context, |
| 179 const std::string& value, | 198 const std::string& value, |
| 180 int item_index, | 199 int item_index, |
| 181 int item_count) | 200 int item_count) |
| 182 : AccessibilityControlInfo(profile, name), | 201 : AccessibilityControlInfo(profile, name), |
| 183 value_(value), | 202 value_(value), |
| 184 item_index_(item_index), | 203 item_index_(item_index), |
| 185 item_count_(item_count) { | 204 item_count_(item_count) { |
| 205 set_context(context); |
| 186 } | 206 } |
| 187 | 207 |
| 188 const char* AccessibilityListBoxInfo::type() const { | 208 const char* AccessibilityListBoxInfo::type() const { |
| 189 return keys::kTypeListBox; | 209 return keys::kTypeListBox; |
| 190 } | 210 } |
| 191 | 211 |
| 192 void AccessibilityListBoxInfo::SerializeToDict(DictionaryValue *dict) const { | 212 void AccessibilityListBoxInfo::SerializeToDict(DictionaryValue *dict) const { |
| 193 AccessibilityControlInfo::SerializeToDict(dict); | 213 AccessibilityControlInfo::SerializeToDict(dict); |
| 194 dict->SetString(keys::kValueKey, value_); | 214 dict->SetString(keys::kValueKey, value_); |
| 195 dict->SetInteger(keys::kItemIndexKey, item_index_); | 215 dict->SetInteger(keys::kItemIndexKey, item_index_); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 const std::string& menu_name) | 250 const std::string& menu_name) |
| 231 : AccessibilityControlInfo(profile, menu_name) { | 251 : AccessibilityControlInfo(profile, menu_name) { |
| 232 } | 252 } |
| 233 | 253 |
| 234 const char* AccessibilityMenuInfo::type() const { | 254 const char* AccessibilityMenuInfo::type() const { |
| 235 return keys::kTypeMenu; | 255 return keys::kTypeMenu; |
| 236 } | 256 } |
| 237 | 257 |
| 238 AccessibilityMenuItemInfo::AccessibilityMenuItemInfo(Profile* profile, | 258 AccessibilityMenuItemInfo::AccessibilityMenuItemInfo(Profile* profile, |
| 239 const std::string& name, | 259 const std::string& name, |
| 260 const std::string& context, |
| 240 bool has_submenu, | 261 bool has_submenu, |
| 241 int item_index, | 262 int item_index, |
| 242 int item_count) | 263 int item_count) |
| 243 : AccessibilityControlInfo(profile, name), | 264 : AccessibilityControlInfo(profile, name), |
| 244 has_submenu_(has_submenu), | 265 has_submenu_(has_submenu), |
| 245 item_index_(item_index), | 266 item_index_(item_index), |
| 246 item_count_(item_count) { | 267 item_count_(item_count) { |
| 268 set_context(context); |
| 247 } | 269 } |
| 248 | 270 |
| 249 const char* AccessibilityMenuItemInfo::type() const { | 271 const char* AccessibilityMenuItemInfo::type() const { |
| 250 return keys::kTypeMenuItem; | 272 return keys::kTypeMenuItem; |
| 251 } | 273 } |
| 252 | 274 |
| 253 void AccessibilityMenuItemInfo::SerializeToDict(DictionaryValue *dict) const { | 275 void AccessibilityMenuItemInfo::SerializeToDict(DictionaryValue *dict) const { |
| 254 AccessibilityControlInfo::SerializeToDict(dict); | 276 AccessibilityControlInfo::SerializeToDict(dict); |
| 255 dict->SetBoolean(keys::kHasSubmenuKey, has_submenu_); | 277 dict->SetBoolean(keys::kHasSubmenuKey, has_submenu_); |
| 256 dict->SetInteger(keys::kItemIndexKey, item_index_); | 278 dict->SetInteger(keys::kItemIndexKey, item_index_); |
| 257 dict->SetInteger(keys::kItemCountKey, item_count_); | 279 dict->SetInteger(keys::kItemCountKey, item_count_); |
| 258 } | 280 } |
| OLD | NEW |