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/chromeos/login/wizard_accessibility_handler.h" | 5 #include "chrome/browser/chromeos/login/wizard_accessibility_handler.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/i18n/char_iterator.h" | 9 #include "base/i18n/char_iterator.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 AppendUtterance(l10n_util::GetStringFUTF8(IDS_CHROMEOS_ACC_INDEX_OF_COUNT, | 93 AppendUtterance(l10n_util::GetStringFUTF8(IDS_CHROMEOS_ACC_INDEX_OF_COUNT, |
94 index_str, | 94 index_str, |
95 count_str), str); | 95 count_str), str); |
96 } | 96 } |
97 | 97 |
98 } // anonymous namespace | 98 } // anonymous namespace |
99 | 99 |
100 namespace chromeos { | 100 namespace chromeos { |
101 | 101 |
102 void WizardAccessibilityHandler::Observe( | 102 void WizardAccessibilityHandler::Observe( |
103 NotificationType type, | 103 int type, |
104 const NotificationSource& source, | 104 const NotificationSource& source, |
105 const NotificationDetails& details) { | 105 const NotificationDetails& details) { |
106 const AccessibilityControlInfo *control_info = | 106 const AccessibilityControlInfo *control_info = |
107 Details<const AccessibilityControlInfo>(details).ptr(); | 107 Details<const AccessibilityControlInfo>(details).ptr(); |
108 std::string description; | 108 std::string description; |
109 EarconType earcon = NO_EARCON; | 109 EarconType earcon = NO_EARCON; |
110 DescribeAccessibilityEvent(type, control_info, &description, &earcon); | 110 DescribeAccessibilityEvent(type, control_info, &description, &earcon); |
111 Speak(description.c_str(), false, true); | 111 Speak(description.c_str(), false, true); |
112 } | 112 } |
113 | 113 |
114 void WizardAccessibilityHandler::Speak(const char* speak_str, | 114 void WizardAccessibilityHandler::Speak(const char* speak_str, |
115 bool queue, | 115 bool queue, |
116 bool interruptible) { | 116 bool interruptible) { |
117 if (chromeos::CrosLibrary::Get()->EnsureLoaded()) { | 117 if (chromeos::CrosLibrary::Get()->EnsureLoaded()) { |
118 if (queue || !interruptible) { | 118 if (queue || !interruptible) { |
119 std::string props = ""; | 119 std::string props = ""; |
120 props.append("enqueue="); | 120 props.append("enqueue="); |
121 props.append(queue ? "1;" : "0;"); | 121 props.append(queue ? "1;" : "0;"); |
122 props.append("interruptible="); | 122 props.append("interruptible="); |
123 props.append(interruptible ? "1;" : "0;"); | 123 props.append(interruptible ? "1;" : "0;"); |
124 chromeos::CrosLibrary::Get()->GetSpeechSynthesisLibrary()-> | 124 chromeos::CrosLibrary::Get()->GetSpeechSynthesisLibrary()-> |
125 SetSpeakProperties(props.c_str()); | 125 SetSpeakProperties(props.c_str()); |
126 } | 126 } |
127 chromeos::CrosLibrary::Get()->GetSpeechSynthesisLibrary()-> | 127 chromeos::CrosLibrary::Get()->GetSpeechSynthesisLibrary()-> |
128 Speak(speak_str); | 128 Speak(speak_str); |
129 } | 129 } |
130 } | 130 } |
131 | 131 |
132 void WizardAccessibilityHandler::DescribeAccessibilityEvent( | 132 void WizardAccessibilityHandler::DescribeAccessibilityEvent( |
133 NotificationType event_type, | 133 int event_type, |
134 const AccessibilityControlInfo* control_info, | 134 const AccessibilityControlInfo* control_info, |
135 std::string* out_spoken_description, | 135 std::string* out_spoken_description, |
136 EarconType* out_earcon) { | 136 EarconType* out_earcon) { |
137 *out_spoken_description = std::string(); | 137 *out_spoken_description = std::string(); |
138 *out_earcon = NO_EARCON; | 138 *out_earcon = NO_EARCON; |
139 | 139 |
140 switch (event_type.value) { | 140 switch (event_type) { |
141 case NotificationType::ACCESSIBILITY_CONTROL_FOCUSED: | 141 case chrome::ACCESSIBILITY_CONTROL_FOCUSED: |
142 DescribeControl(control_info, false, out_spoken_description, out_earcon); | 142 DescribeControl(control_info, false, out_spoken_description, out_earcon); |
143 break; | 143 break; |
144 case NotificationType::ACCESSIBILITY_CONTROL_ACTION: | 144 case chrome::ACCESSIBILITY_CONTROL_ACTION: |
145 DescribeControl(control_info, true, out_spoken_description, out_earcon); | 145 DescribeControl(control_info, true, out_spoken_description, out_earcon); |
146 break; | 146 break; |
147 case NotificationType::ACCESSIBILITY_TEXT_CHANGED: | 147 case chrome::ACCESSIBILITY_TEXT_CHANGED: |
148 DescribeTextChanged(control_info, out_spoken_description, out_earcon); | 148 DescribeTextChanged(control_info, out_spoken_description, out_earcon); |
149 break; | 149 break; |
150 case NotificationType::ACCESSIBILITY_MENU_OPENED: | 150 case chrome::ACCESSIBILITY_MENU_OPENED: |
151 *out_earcon = EARCON_OBJECT_OPENED; | 151 *out_earcon = EARCON_OBJECT_OPENED; |
152 break; | 152 break; |
153 case NotificationType::ACCESSIBILITY_MENU_CLOSED: | 153 case chrome::ACCESSIBILITY_MENU_CLOSED: |
154 *out_earcon = EARCON_OBJECT_CLOSED; | 154 *out_earcon = EARCON_OBJECT_CLOSED; |
155 break; | 155 break; |
156 default: | 156 default: |
157 NOTREACHED(); | 157 NOTREACHED(); |
158 return; | 158 return; |
159 } | 159 } |
160 | 160 |
161 if (control_info->type() == keys::kTypeTextBox) { | 161 if (control_info->type() == keys::kTypeTextBox) { |
162 const AccessibilityTextBoxInfo* text_box = | 162 const AccessibilityTextBoxInfo* text_box = |
163 static_cast<const AccessibilityTextBoxInfo*>(control_info); | 163 static_cast<const AccessibilityTextBoxInfo*>(control_info); |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 } else if (!inserted.empty()) { | 436 } else if (!inserted.empty()) { |
437 // Speak inserted text. | 437 // Speak inserted text. |
438 AppendUtterance(inserted, out_spoken_description); | 438 AppendUtterance(inserted, out_spoken_description); |
439 } else if (!deleted.empty()) { | 439 } else if (!deleted.empty()) { |
440 // Speak deleted text. | 440 // Speak deleted text. |
441 AppendUtterance(deleted, out_spoken_description); | 441 AppendUtterance(deleted, out_spoken_description); |
442 } | 442 } |
443 } | 443 } |
444 | 444 |
445 } // namespace chromeos | 445 } // namespace chromeos |
OLD | NEW |