| 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 #ifndef CHROME_BROWSER_ACCESSIBILITY_EVENTS_H_ | 5 #ifndef CHROME_BROWSER_ACCESSIBILITY_EVENTS_H_ |
| 6 #define CHROME_BROWSER_ACCESSIBILITY_EVENTS_H_ | 6 #define CHROME_BROWSER_ACCESSIBILITY_EVENTS_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 class AccessibilityControlInfo; | 11 class AccessibilityControlInfo; |
| 12 class Profile; |
| 13 |
| 14 namespace base { |
| 12 class DictionaryValue; | 15 class DictionaryValue; |
| 13 class Profile; | 16 } |
| 14 | 17 |
| 15 // Use the NotificationService to post the given accessibility | 18 // Use the NotificationService to post the given accessibility |
| 16 // notification type with AccessibilityControlInfo details to any | 19 // notification type with AccessibilityControlInfo details to any |
| 17 // listeners. Will not send if the profile's pause level is nonzero | 20 // listeners. Will not send if the profile's pause level is nonzero |
| 18 // (using profile->PauseAccessibilityEvents). | 21 // (using profile->PauseAccessibilityEvents). |
| 19 void SendAccessibilityNotification( | 22 void SendAccessibilityNotification( |
| 20 int type, AccessibilityControlInfo* info); | 23 int type, AccessibilityControlInfo* info); |
| 21 | 24 |
| 22 // Abstract parent class for accessibility information about a control | 25 // Abstract parent class for accessibility information about a control |
| 23 // passed to event listeners. | 26 // passed to event listeners. |
| 24 class AccessibilityControlInfo { | 27 class AccessibilityControlInfo { |
| 25 public: | 28 public: |
| 26 virtual ~AccessibilityControlInfo(); | 29 virtual ~AccessibilityControlInfo(); |
| 27 | 30 |
| 28 // Serialize this class as a DictionaryValue that can be converted to | 31 // Serialize this class as a DictionaryValue that can be converted to |
| 29 // a JavaScript object. | 32 // a JavaScript object. |
| 30 virtual void SerializeToDict(DictionaryValue* dict) const; | 33 virtual void SerializeToDict(base::DictionaryValue* dict) const; |
| 31 | 34 |
| 32 // Return the specific type of this control, which will be one of the | 35 // Return the specific type of this control, which will be one of the |
| 33 // string constants defined in extension_accessibility_api_constants.h. | 36 // string constants defined in extension_accessibility_api_constants.h. |
| 34 virtual const char* type() const = 0; | 37 virtual const char* type() const = 0; |
| 35 | 38 |
| 36 Profile* profile() const { return profile_; } | 39 Profile* profile() const { return profile_; } |
| 37 | 40 |
| 38 const std::string& name() const { return name_; } | 41 const std::string& name() const { return name_; } |
| 39 | 42 |
| 40 protected: | 43 protected: |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 class AccessibilityRadioButtonInfo : public AccessibilityControlInfo { | 82 class AccessibilityRadioButtonInfo : public AccessibilityControlInfo { |
| 80 public: | 83 public: |
| 81 AccessibilityRadioButtonInfo(Profile* profile, | 84 AccessibilityRadioButtonInfo(Profile* profile, |
| 82 const std::string& name, | 85 const std::string& name, |
| 83 bool checked, | 86 bool checked, |
| 84 int item_index, | 87 int item_index, |
| 85 int item_count); | 88 int item_count); |
| 86 | 89 |
| 87 virtual const char* type() const; | 90 virtual const char* type() const; |
| 88 | 91 |
| 89 virtual void SerializeToDict(DictionaryValue* dict) const; | 92 virtual void SerializeToDict(base::DictionaryValue* dict) const; |
| 90 | 93 |
| 91 void SetChecked(bool checked) { checked_ = checked; } | 94 void SetChecked(bool checked) { checked_ = checked; } |
| 92 | 95 |
| 93 int item_index() const { return item_index_; } | 96 int item_index() const { return item_index_; } |
| 94 int item_count() const { return item_count_; } | 97 int item_count() const { return item_count_; } |
| 95 bool checked() const { return checked_; } | 98 bool checked() const { return checked_; } |
| 96 | 99 |
| 97 private: | 100 private: |
| 98 bool checked_; | 101 bool checked_; |
| 99 // The 0-based index of this radio button and number of buttons in the group. | 102 // The 0-based index of this radio button and number of buttons in the group. |
| 100 int item_index_; | 103 int item_index_; |
| 101 int item_count_; | 104 int item_count_; |
| 102 }; | 105 }; |
| 103 | 106 |
| 104 // Accessibility information about a checkbox passed to onControlFocused | 107 // Accessibility information about a checkbox passed to onControlFocused |
| 105 // and onControlAction event listeners. | 108 // and onControlAction event listeners. |
| 106 class AccessibilityCheckboxInfo : public AccessibilityControlInfo { | 109 class AccessibilityCheckboxInfo : public AccessibilityControlInfo { |
| 107 public: | 110 public: |
| 108 AccessibilityCheckboxInfo(Profile* profile, | 111 AccessibilityCheckboxInfo(Profile* profile, |
| 109 const std::string& name, | 112 const std::string& name, |
| 110 bool checked); | 113 bool checked); |
| 111 | 114 |
| 112 virtual const char* type() const; | 115 virtual const char* type() const; |
| 113 | 116 |
| 114 virtual void SerializeToDict(DictionaryValue* dict) const; | 117 virtual void SerializeToDict(base::DictionaryValue* dict) const; |
| 115 | 118 |
| 116 void SetChecked(bool checked) { checked_ = checked; } | 119 void SetChecked(bool checked) { checked_ = checked; } |
| 117 | 120 |
| 118 bool checked() const { return checked_; } | 121 bool checked() const { return checked_; } |
| 119 | 122 |
| 120 private: | 123 private: |
| 121 bool checked_; | 124 bool checked_; |
| 122 }; | 125 }; |
| 123 | 126 |
| 124 // Accessibility information about a tab passed to onControlFocused | 127 // Accessibility information about a tab passed to onControlFocused |
| 125 // and onControlAction event listeners. | 128 // and onControlAction event listeners. |
| 126 class AccessibilityTabInfo : public AccessibilityControlInfo { | 129 class AccessibilityTabInfo : public AccessibilityControlInfo { |
| 127 public: | 130 public: |
| 128 AccessibilityTabInfo(Profile* profile, | 131 AccessibilityTabInfo(Profile* profile, |
| 129 const std::string& tab_name, | 132 const std::string& tab_name, |
| 130 int tab_index, | 133 int tab_index, |
| 131 int tab_count); | 134 int tab_count); |
| 132 | 135 |
| 133 virtual const char* type() const; | 136 virtual const char* type() const; |
| 134 | 137 |
| 135 virtual void SerializeToDict(DictionaryValue* dict) const; | 138 virtual void SerializeToDict(base::DictionaryValue* dict) const; |
| 136 | 139 |
| 137 void SetTab(int tab_index, std::string tab_name) { | 140 void SetTab(int tab_index, std::string tab_name) { |
| 138 tab_index_ = tab_index; | 141 tab_index_ = tab_index; |
| 139 name_ = tab_name; | 142 name_ = tab_name; |
| 140 } | 143 } |
| 141 | 144 |
| 142 int tab_index() const { return tab_index_; } | 145 int tab_index() const { return tab_index_; } |
| 143 int tab_count() const { return tab_count_; } | 146 int tab_count() const { return tab_count_; } |
| 144 | 147 |
| 145 private: | 148 private: |
| 146 // The 0-based index of this tab and number of tabs in the group. | 149 // The 0-based index of this tab and number of tabs in the group. |
| 147 int tab_index_; | 150 int tab_index_; |
| 148 int tab_count_; | 151 int tab_count_; |
| 149 }; | 152 }; |
| 150 | 153 |
| 151 // Accessibility information about a combo box passed to onControlFocused | 154 // Accessibility information about a combo box passed to onControlFocused |
| 152 // and onControlAction event listeners. | 155 // and onControlAction event listeners. |
| 153 class AccessibilityComboBoxInfo : public AccessibilityControlInfo { | 156 class AccessibilityComboBoxInfo : public AccessibilityControlInfo { |
| 154 public: | 157 public: |
| 155 AccessibilityComboBoxInfo(Profile* profile, | 158 AccessibilityComboBoxInfo(Profile* profile, |
| 156 const std::string& name, | 159 const std::string& name, |
| 157 const std::string& value, | 160 const std::string& value, |
| 158 int item_index, | 161 int item_index, |
| 159 int item_count); | 162 int item_count); |
| 160 | 163 |
| 161 virtual const char* type() const; | 164 virtual const char* type() const; |
| 162 | 165 |
| 163 virtual void SerializeToDict(DictionaryValue* dict) const; | 166 virtual void SerializeToDict(base::DictionaryValue* dict) const; |
| 164 | 167 |
| 165 void SetValue(int item_index, const std::string& value) { | 168 void SetValue(int item_index, const std::string& value) { |
| 166 item_index_ = item_index; | 169 item_index_ = item_index; |
| 167 value_ = value; | 170 value_ = value; |
| 168 } | 171 } |
| 169 | 172 |
| 170 int item_index() const { return item_index_; } | 173 int item_index() const { return item_index_; } |
| 171 int item_count() const { return item_count_; } | 174 int item_count() const { return item_count_; } |
| 172 const std::string& value() const { return value_; } | 175 const std::string& value() const { return value_; } |
| 173 | 176 |
| 174 private: | 177 private: |
| 175 std::string value_; | 178 std::string value_; |
| 176 // The 0-based index of the current item and the number of total items. | 179 // The 0-based index of the current item and the number of total items. |
| 177 // If the value is not one of the drop-down options, |item_index_| should | 180 // If the value is not one of the drop-down options, |item_index_| should |
| 178 // be -1. | 181 // be -1. |
| 179 int item_index_; | 182 int item_index_; |
| 180 int item_count_; | 183 int item_count_; |
| 181 }; | 184 }; |
| 182 | 185 |
| 183 // Accessibility information about a text box, passed to onControlFocused, | 186 // Accessibility information about a text box, passed to onControlFocused, |
| 184 // onControlAction, and onTextChanged event listeners. | 187 // onControlAction, and onTextChanged event listeners. |
| 185 class AccessibilityTextBoxInfo : public AccessibilityControlInfo { | 188 class AccessibilityTextBoxInfo : public AccessibilityControlInfo { |
| 186 public: | 189 public: |
| 187 AccessibilityTextBoxInfo(Profile* profile, | 190 AccessibilityTextBoxInfo(Profile* profile, |
| 188 const std::string& name, | 191 const std::string& name, |
| 189 bool password); | 192 bool password); |
| 190 | 193 |
| 191 virtual const char* type() const; | 194 virtual const char* type() const; |
| 192 | 195 |
| 193 virtual void SerializeToDict(DictionaryValue* dict) const; | 196 virtual void SerializeToDict(base::DictionaryValue* dict) const; |
| 194 | 197 |
| 195 void SetValue( | 198 void SetValue( |
| 196 const std::string& value, int selection_start, int selection_end) { | 199 const std::string& value, int selection_start, int selection_end) { |
| 197 value_ = value; | 200 value_ = value; |
| 198 selection_start_ = selection_start; | 201 selection_start_ = selection_start; |
| 199 selection_end_ = selection_end; | 202 selection_end_ = selection_end; |
| 200 } | 203 } |
| 201 | 204 |
| 202 const std::string& value() const { return value_; } | 205 const std::string& value() const { return value_; } |
| 203 bool password() const { return password_; } | 206 bool password() const { return password_; } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 216 class AccessibilityListBoxInfo : public AccessibilityControlInfo { | 219 class AccessibilityListBoxInfo : public AccessibilityControlInfo { |
| 217 public: | 220 public: |
| 218 AccessibilityListBoxInfo(Profile* profile, | 221 AccessibilityListBoxInfo(Profile* profile, |
| 219 const std::string& name, | 222 const std::string& name, |
| 220 const std::string& value, | 223 const std::string& value, |
| 221 int item_index, | 224 int item_index, |
| 222 int item_count); | 225 int item_count); |
| 223 | 226 |
| 224 virtual const char* type() const; | 227 virtual const char* type() const; |
| 225 | 228 |
| 226 virtual void SerializeToDict(DictionaryValue* dict) const; | 229 virtual void SerializeToDict(base::DictionaryValue* dict) const; |
| 227 | 230 |
| 228 void SetValue(int item_index, std::string value) { | 231 void SetValue(int item_index, std::string value) { |
| 229 item_index_ = item_index; | 232 item_index_ = item_index; |
| 230 value_ = value; | 233 value_ = value; |
| 231 } | 234 } |
| 232 | 235 |
| 233 int item_index() const { return item_index_; } | 236 int item_index() const { return item_index_; } |
| 234 int item_count() const { return item_count_; } | 237 int item_count() const { return item_count_; } |
| 235 const std::string& value() const { return value_; } | 238 const std::string& value() const { return value_; } |
| 236 | 239 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 257 class AccessibilityMenuItemInfo : public AccessibilityControlInfo { | 260 class AccessibilityMenuItemInfo : public AccessibilityControlInfo { |
| 258 public: | 261 public: |
| 259 AccessibilityMenuItemInfo(Profile* profile, | 262 AccessibilityMenuItemInfo(Profile* profile, |
| 260 const std::string& name, | 263 const std::string& name, |
| 261 bool has_submenu, | 264 bool has_submenu, |
| 262 int item_index, | 265 int item_index, |
| 263 int item_count); | 266 int item_count); |
| 264 | 267 |
| 265 virtual const char* type() const; | 268 virtual const char* type() const; |
| 266 | 269 |
| 267 virtual void SerializeToDict(DictionaryValue* dict) const; | 270 virtual void SerializeToDict(base::DictionaryValue* dict) const; |
| 268 | 271 |
| 269 int item_index() const { return item_index_; } | 272 int item_index() const { return item_index_; } |
| 270 int item_count() const { return item_count_; } | 273 int item_count() const { return item_count_; } |
| 271 bool has_submenu() const { return has_submenu_; } | 274 bool has_submenu() const { return has_submenu_; } |
| 272 | 275 |
| 273 private: | 276 private: |
| 274 bool has_submenu_; | 277 bool has_submenu_; |
| 275 // The 0-based index of the current item and the number of total items. | 278 // The 0-based index of the current item and the number of total items. |
| 276 int item_index_; | 279 int item_index_; |
| 277 int item_count_; | 280 int item_count_; |
| 278 }; | 281 }; |
| 279 | 282 |
| 280 #endif // CHROME_BROWSER_ACCESSIBILITY_EVENTS_H_ | 283 #endif // CHROME_BROWSER_ACCESSIBILITY_EVENTS_H_ |
| OLD | NEW |