| 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 #include "base/compiler_specific.h" |
| 10 | 11 |
| 11 class AccessibilityControlInfo; | 12 class AccessibilityEventInfo; |
| 12 class Profile; | 13 class Profile; |
| 13 | 14 |
| 14 namespace base { | 15 namespace base { |
| 15 class DictionaryValue; | 16 class DictionaryValue; |
| 16 } | 17 } |
| 17 | 18 |
| 18 // Use the NotificationService to post the given accessibility | 19 // Use the NotificationService to post the given accessibility |
| 19 // notification type with AccessibilityControlInfo details to any | 20 // notification type with AccessibilityEventInfo details to any |
| 20 // listeners. Will not send if the profile's pause level is nonzero | 21 // listeners. Will not send if the profile's pause level is nonzero |
| 21 // (using profile->PauseAccessibilityEvents). | 22 // (using profile->PauseAccessibilityEvents). |
| 22 void SendAccessibilityNotification( | 23 void SendAccessibilityNotification( |
| 23 int type, AccessibilityControlInfo* info); | 24 int type, AccessibilityEventInfo* info); |
| 25 void SendAccessibilityVolumeNotification(double volume, bool is_muted); |
| 26 |
| 27 // Abstract parent class for accessibility event information passed to event |
| 28 // listeners. |
| 29 class AccessibilityEventInfo { |
| 30 public: |
| 31 virtual ~AccessibilityEventInfo() {} |
| 32 |
| 33 // Serialize this class as a DictionaryValue that can be converted to |
| 34 // a JavaScript object. |
| 35 virtual void SerializeToDict(base::DictionaryValue* dict) const = 0; |
| 36 |
| 37 Profile* profile() const { return profile_; } |
| 38 |
| 39 protected: |
| 40 explicit AccessibilityEventInfo(Profile* profile) : profile_(profile) {} |
| 41 |
| 42 // The profile this control belongs to. |
| 43 Profile* profile_; |
| 44 }; |
| 24 | 45 |
| 25 // Abstract parent class for accessibility information about a control | 46 // Abstract parent class for accessibility information about a control |
| 26 // passed to event listeners. | 47 // passed to event listeners. |
| 27 class AccessibilityControlInfo { | 48 class AccessibilityControlInfo : public AccessibilityEventInfo { |
| 28 public: | 49 public: |
| 29 virtual ~AccessibilityControlInfo(); | 50 virtual ~AccessibilityControlInfo(); |
| 30 | 51 |
| 31 // Serialize this class as a DictionaryValue that can be converted to | 52 // Serialize this class as a DictionaryValue that can be converted to |
| 32 // a JavaScript object. | 53 // a JavaScript object. |
| 33 virtual void SerializeToDict(base::DictionaryValue* dict) const; | 54 virtual void SerializeToDict(base::DictionaryValue* dict) const OVERRIDE; |
| 34 | 55 |
| 35 // Return the specific type of this control, which will be one of the | 56 // Return the specific type of this control, which will be one of the |
| 36 // string constants defined in extension_accessibility_api_constants.h. | 57 // string constants defined in extension_accessibility_api_constants.h. |
| 37 virtual const char* type() const = 0; | 58 virtual const char* type() const = 0; |
| 38 | 59 |
| 39 Profile* profile() const { return profile_; } | |
| 40 | |
| 41 const std::string& name() const { return name_; } | 60 const std::string& name() const { return name_; } |
| 42 | 61 |
| 43 protected: | 62 protected: |
| 44 AccessibilityControlInfo(Profile* profile, const std::string& control_name); | 63 AccessibilityControlInfo(Profile* profile, const std::string& control_name); |
| 45 | 64 |
| 46 // The profile this control belongs to. | |
| 47 Profile* profile_; | |
| 48 | |
| 49 // The name of the control, like "OK" or "Password". | 65 // The name of the control, like "OK" or "Password". |
| 50 std::string name_; | 66 std::string name_; |
| 51 }; | 67 }; |
| 52 | 68 |
| 53 // Accessibility information about a window passed to onWindowOpened | 69 // Accessibility information about a window passed to onWindowOpened |
| 54 // and onWindowClosed event listeners. | 70 // and onWindowClosed event listeners. |
| 55 class AccessibilityWindowInfo : public AccessibilityControlInfo { | 71 class AccessibilityWindowInfo : public AccessibilityControlInfo { |
| 56 public: | 72 public: |
| 57 AccessibilityWindowInfo(Profile* profile, const std::string& window_name); | 73 AccessibilityWindowInfo(Profile* profile, const std::string& window_name); |
| 58 | 74 |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 | 264 |
| 249 // Accessibility information about a menu; this class is used by | 265 // Accessibility information about a menu; this class is used by |
| 250 // onMenuOpened, onMenuClosed, and onControlFocused event listeners. | 266 // onMenuOpened, onMenuClosed, and onControlFocused event listeners. |
| 251 class AccessibilityMenuInfo : public AccessibilityControlInfo { | 267 class AccessibilityMenuInfo : public AccessibilityControlInfo { |
| 252 public: | 268 public: |
| 253 AccessibilityMenuInfo(Profile* profile, const std::string& menu_name); | 269 AccessibilityMenuInfo(Profile* profile, const std::string& menu_name); |
| 254 | 270 |
| 255 virtual const char* type() const; | 271 virtual const char* type() const; |
| 256 }; | 272 }; |
| 257 | 273 |
| 274 // Accessibility information about a volume; this class is used by |
| 275 // onVolumeUp, onVolumeDown, and onVolumeMute event listeners. |
| 276 class AccessibilityVolumeInfo : public AccessibilityEventInfo { |
| 277 public: |
| 278 // |volume| must range between 0 to 100. |
| 279 AccessibilityVolumeInfo(Profile* profile, double volume, bool is_muted); |
| 280 |
| 281 virtual void SerializeToDict(base::DictionaryValue* dict) const; |
| 282 |
| 283 private: |
| 284 double volume_; |
| 285 bool is_muted_; |
| 286 }; |
| 287 |
| 258 // Accessibility information about a menu item; this class is used by | 288 // Accessibility information about a menu item; this class is used by |
| 259 // onControlFocused event listeners. | 289 // onControlFocused event listeners. |
| 260 class AccessibilityMenuItemInfo : public AccessibilityControlInfo { | 290 class AccessibilityMenuItemInfo : public AccessibilityControlInfo { |
| 261 public: | 291 public: |
| 262 AccessibilityMenuItemInfo(Profile* profile, | 292 AccessibilityMenuItemInfo(Profile* profile, |
| 263 const std::string& name, | 293 const std::string& name, |
| 264 bool has_submenu, | 294 bool has_submenu, |
| 265 int item_index, | 295 int item_index, |
| 266 int item_count); | 296 int item_count); |
| 267 | 297 |
| 268 virtual const char* type() const; | 298 virtual const char* type() const; |
| 269 | 299 |
| 270 virtual void SerializeToDict(base::DictionaryValue* dict) const; | 300 virtual void SerializeToDict(base::DictionaryValue* dict) const; |
| 271 | 301 |
| 272 int item_index() const { return item_index_; } | 302 int item_index() const { return item_index_; } |
| 273 int item_count() const { return item_count_; } | 303 int item_count() const { return item_count_; } |
| 274 bool has_submenu() const { return has_submenu_; } | 304 bool has_submenu() const { return has_submenu_; } |
| 275 | 305 |
| 276 private: | 306 private: |
| 277 bool has_submenu_; | 307 bool has_submenu_; |
| 278 // The 0-based index of the current item and the number of total items. | 308 // The 0-based index of the current item and the number of total items. |
| 279 int item_index_; | 309 int item_index_; |
| 280 int item_count_; | 310 int item_count_; |
| 281 }; | 311 }; |
| 282 | 312 |
| 283 #endif // CHROME_BROWSER_ACCESSIBILITY_EVENTS_H_ | 313 #endif // CHROME_BROWSER_ACCESSIBILITY_EVENTS_H_ |
| OLD | NEW |