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