Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "base/i18n/char_iterator.h" | 10 #include "base/i18n/char_iterator.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/scoped_ptr.h" | 12 #include "base/scoped_ptr.h" |
| 13 #include "base/string_number_conversions.h" | 13 #include "base/string_number_conversions.h" |
| 14 #include "chrome/browser/accessibility_events.h" | 14 #include "chrome/browser/accessibility_events.h" |
| 15 #include "chrome/browser/chromeos/cros/cros_library.h" | 15 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 16 #include "chrome/browser/chromeos/cros/speech_synthesis_library.h" | |
| 17 #include "chrome/browser/extensions/extension_accessibility_api.h" | 16 #include "chrome/browser/extensions/extension_accessibility_api.h" |
| 18 #include "chrome/browser/extensions/extension_accessibility_api_constants.h" | 17 #include "chrome/browser/extensions/extension_accessibility_api_constants.h" |
| 19 #include "chrome/browser/profiles/profile_manager.h" | 18 #include "chrome/browser/profiles/profile_manager.h" |
| 20 #include "chrome/common/notification_registrar.h" | 19 #include "chrome/common/notification_registrar.h" |
| 21 #include "chrome/common/notification_service.h" | 20 #include "chrome/common/notification_service.h" |
| 22 #include "grit/generated_resources.h" | 21 #include "grit/generated_resources.h" |
| 23 | 22 |
| 23 #include <fstream> | |
| 24 #include <iostream> | |
| 25 | |
| 24 namespace keys = extension_accessibility_api_constants; | 26 namespace keys = extension_accessibility_api_constants; |
| 25 | 27 |
| 26 namespace { | 28 namespace { |
| 27 | 29 |
| 28 static std::string SubstringUTF8(std::string str, int start, int len) { | 30 static std::string SubstringUTF8(std::string str, int start, int len) { |
| 29 base::UTF8CharIterator iter(&str); | 31 base::UTF8CharIterator iter(&str); |
| 30 for (int i = 0; i < start; i++) { | 32 for (int i = 0; i < start; i++) { |
| 31 if (!iter.Advance()) | 33 if (!iter.Advance()) |
| 32 return std::string(); | 34 return std::string(); |
| 33 } | 35 } |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 102 void WizardAccessibilityHandler::Observe( | 104 void WizardAccessibilityHandler::Observe( |
| 103 NotificationType type, | 105 NotificationType type, |
| 104 const NotificationSource& source, | 106 const NotificationSource& source, |
| 105 const NotificationDetails& details) { | 107 const NotificationDetails& details) { |
| 106 const AccessibilityControlInfo *control_info = | 108 const AccessibilityControlInfo *control_info = |
| 107 Details<const AccessibilityControlInfo>(details).ptr(); | 109 Details<const AccessibilityControlInfo>(details).ptr(); |
| 108 std::string description; | 110 std::string description; |
| 109 EarconType earcon = NO_EARCON; | 111 EarconType earcon = NO_EARCON; |
| 110 DescribeAccessibilityEvent(type, control_info, &description, &earcon); | 112 DescribeAccessibilityEvent(type, control_info, &description, &earcon); |
| 111 Speak(description.c_str(), false, true); | 113 Speak(description.c_str(), false, true); |
| 114 std::ofstream st; | |
| 115 st.open("/tmp/mydebug.txt", std::ios::app); | |
| 116 st << "Will this Play earcon???\n"; | |
| 117 if (earcon != NO_EARCON) { | |
| 118 st << "Playing earcon: " << earcon << "\n"; | |
| 119 st.close(); | |
| 120 PlayEarcon(earcon); | |
| 121 } else { | |
| 122 st.close(); | |
| 123 } | |
|
xiyuan
2010/12/15 22:44:52
/tmp/mydebug.txt is debugging code, right? If so,
| |
| 124 } | |
| 125 | |
| 126 void WizardAccessibilityHandler::PlayEarcon(EarconType earcon_type) { | |
| 127 std::ofstream st; | |
| 128 st.open("/tmp/mydebug.txt", std::ios::app); | |
| 129 st << "Is cros loaded???\n"; | |
| 130 if (chromeos::CrosLibrary::Get()->EnsureLoaded()) { | |
| 131 st << "Cros loaded... will play earcon now...\n"; | |
| 132 st.close(); | |
| 133 chromeos::CrosLibrary::Get()->GetSpeechSynthesisLibrary()-> | |
| 134 PlayEarcon(earcon_type); | |
| 135 } else { | |
| 136 st.close(); | |
| 137 } | |
|
xiyuan
2010/12/15 22:44:52
please clean up the debug code.
| |
| 112 } | 138 } |
| 113 | 139 |
| 114 void WizardAccessibilityHandler::Speak(const char* speak_str, | 140 void WizardAccessibilityHandler::Speak(const char* speak_str, |
| 115 bool queue, | 141 bool queue, |
| 116 bool interruptible) { | 142 bool interruptible) { |
| 117 if (chromeos::CrosLibrary::Get()->EnsureLoaded()) { | 143 if (chromeos::CrosLibrary::Get()->EnsureLoaded()) { |
| 118 if (queue || !interruptible) { | 144 if (queue || !interruptible) { |
| 119 std::string props = ""; | 145 std::string props = ""; |
| 120 props.append("enqueue="); | 146 props.append("enqueue="); |
| 121 props.append(queue ? "1;" : "0;"); | 147 props.append(queue ? "1;" : "0;"); |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 436 } else if (inserted.size() > 0) { | 462 } else if (inserted.size() > 0) { |
| 437 // Speak inserted text. | 463 // Speak inserted text. |
| 438 AppendUtterance(inserted, out_spoken_description); | 464 AppendUtterance(inserted, out_spoken_description); |
| 439 } else if (deleted.size() > 0) { | 465 } else if (deleted.size() > 0) { |
| 440 // Speak deleted text. | 466 // Speak deleted text. |
| 441 AppendUtterance(deleted, out_spoken_description); | 467 AppendUtterance(deleted, out_spoken_description); |
| 442 } | 468 } |
| 443 } | 469 } |
| 444 | 470 |
| 445 } // namespace chromeos | 471 } // namespace chromeos |
| OLD | NEW |