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 3 // found in the LICENSE file. 4 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_WIZARD_ACCESSIBILITY_HANDLER_H_ 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_WIZARD_ACCESSIBILITY_HANDLER_H_ 7 #pragma once 8 9 #include <string> 10 11 #include "base/gtest_prod_util.h" 12 #include "content/common/notification_observer.h" 13 #include "content/common/notification_source.h" 14 #include "content/common/notification_type.h" 15 16 class AccessibilityControlInfo; 17 class AccessibilityTextBoxInfo; 18 19 namespace chromeos { 20 21 enum EarconType { 22 NO_EARCON, 23 EARCON_BUTTON, 24 EARCON_CHECK_OFF, 25 EARCON_CHECK_ON, 26 EARCON_ELLIPSES, 27 EARCON_LINK, 28 EARCON_LISTBOX, 29 EARCON_MENU, 30 EARCON_OBJECT_OPENED, 31 EARCON_OBJECT_CLOSED, 32 EARCON_TAB, 33 EARCON_TEXTBOX, 34 }; 35 36 // Class that handles the accessibility notifications and generates 37 // appropriate spoken/audio feedback. 38 class WizardAccessibilityHandler : public NotificationObserver { 39 public: 40 WizardAccessibilityHandler() { } 41 42 // Speaks the specified string. 43 void Speak(const char* speak_str, bool queue, bool interruptible); 44 45 private: 46 // Override from NotificationObserver. 47 virtual void Observe(NotificationType type, 48 const NotificationSource& source, 49 const NotificationDetails& details); 50 51 // Get text to speak and an earcon identifier (which may be NONE) for any 52 // accessibility event. 53 void DescribeAccessibilityEvent(NotificationType event_type, 54 const AccessibilityControlInfo* control_info, 55 std::string* out_spoken_description, 56 EarconType* out_earcon); 57 58 // Get text to speak and an optional earcon identifier, specifically for 59 // a focus or select accessibility event on a control. 60 void DescribeControl(const AccessibilityControlInfo* control_info, 61 bool is_action, 62 std::string* out_spoken_description, 63 EarconType* out_earcon); 64 65 // Get text to speak when a text control has changed in some way, either 66 // the contents or selection/cursor. 67 void DescribeTextChanged(const AccessibilityControlInfo* control_info, 68 std::string* out_spoken_description, 69 EarconType* out_earcon); 70 71 // Get the text from an AccessibilityTextBoxInfo, obscuring the 72 // text if it's a password field. 73 std::string GetTextBoxValue(const AccessibilityTextBoxInfo* textbox_info); 74 75 // Get text to speak when only the selection/cursor has changed. 76 void DescribeTextSelectionChanged(const std::string& value, 77 int old_start, int old_end, 78 int new_start, int new_end, 79 std::string* out_spoken_description); 80 81 // Get text to speak when the contents of a text control has changed. 82 void DescribeTextContentsChanged(const std::string& old_value, 83 const std::string& new_value, 84 std::string* out_spoken_description); 85 86 int previous_text_selection_start_; 87 int previous_text_selection_end_; 88 std::string previous_text_value_; 89 90 friend class WizardAccessibilityHandlerTest; 91 FRIEND_TEST_ALL_PREFIXES(WizardAccessibilityHandlerTest, TestFocusEvents); 92 FRIEND_TEST_ALL_PREFIXES(WizardAccessibilityHandlerTest, TestTextEvents); 93 94 DISALLOW_COPY_AND_ASSIGN(WizardAccessibilityHandler); 95 }; 96 97 } // namespace chromeos 98 99 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_WIZARD_ACCESSIBILITY_HANDLER_H_ 100