| 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/accessibility_util.h" | 5 #include "chrome/browser/chromeos/accessibility_util.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| 11 #include "chrome/browser/chromeos/dbus/dbus_thread_manager.h" | |
| 12 #include "chrome/browser/chromeos/dbus/speech_synthesizer_client.h" | |
| 13 #include "chrome/browser/extensions/extension_accessibility_api.h" | 11 #include "chrome/browser/extensions/extension_accessibility_api.h" |
| 12 #include "chrome/browser/extensions/extension_tts_api_platform.h" |
| 14 #include "chrome/browser/extensions/component_loader.h" | 13 #include "chrome/browser/extensions/component_loader.h" |
| 15 #include "chrome/browser/extensions/extension_service.h" | 14 #include "chrome/browser/extensions/extension_service.h" |
| 16 #include "chrome/browser/extensions/file_reader.h" | 15 #include "chrome/browser/extensions/file_reader.h" |
| 17 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
| 18 #include "chrome/browser/profiles/profile_manager.h" | 17 #include "chrome/browser/profiles/profile_manager.h" |
| 19 #include "chrome/common/extensions/extension_messages.h" | 18 #include "chrome/common/extensions/extension_messages.h" |
| 20 #include "chrome/common/extensions/extension_resource.h" | 19 #include "chrome/common/extensions/extension_resource.h" |
| 21 #include "chrome/common/pref_names.h" | 20 #include "chrome/common/pref_names.h" |
| 22 #include "content/browser/renderer_host/render_view_host.h" | 21 #include "content/browser/renderer_host/render_view_host.h" |
| 23 #include "content/browser/tab_contents/tab_contents.h" | 22 #include "content/browser/tab_contents/tab_contents.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 } | 93 } |
| 95 | 94 |
| 96 g_browser_process->local_state()->SetBoolean( | 95 g_browser_process->local_state()->SetBoolean( |
| 97 prefs::kAccessibilityEnabled, enabled); | 96 prefs::kAccessibilityEnabled, enabled); |
| 98 g_browser_process->local_state()->ScheduleSavePersistentPrefs(); | 97 g_browser_process->local_state()->ScheduleSavePersistentPrefs(); |
| 99 ExtensionAccessibilityEventRouter::GetInstance()-> | 98 ExtensionAccessibilityEventRouter::GetInstance()-> |
| 100 SetAccessibilityEnabled(enabled); | 99 SetAccessibilityEnabled(enabled); |
| 101 | 100 |
| 102 Speak(enabled ? | 101 Speak(enabled ? |
| 103 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_ACCESS_ENABLED).c_str() : | 102 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_ACCESS_ENABLED).c_str() : |
| 104 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_ACCESS_DISABLED).c_str(), | 103 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_ACCESS_DISABLED).c_str()); |
| 105 false, true); | |
| 106 | 104 |
| 107 // Load/Unload ChromeVox | 105 // Load/Unload ChromeVox |
| 108 Profile* profile = ProfileManager::GetDefaultProfile(); | 106 Profile* profile = ProfileManager::GetDefaultProfile(); |
| 109 ExtensionService* extension_service = | 107 ExtensionService* extension_service = |
| 110 profile->GetExtensionService(); | 108 profile->GetExtensionService(); |
| 111 std::string manifest = ResourceBundle::GetSharedInstance(). | 109 std::string manifest = ResourceBundle::GetSharedInstance(). |
| 112 GetRawDataResource(IDR_CHROMEVOX_MANIFEST).as_string(); | 110 GetRawDataResource(IDR_CHROMEVOX_MANIFEST).as_string(); |
| 113 FilePath path = FilePath(extension_misc::kAccessExtensionPath) | 111 FilePath path = FilePath(extension_misc::kAccessExtensionPath) |
| 114 .AppendASCII(extension_misc::kChromeVoxDirectoryName); | 112 .AppendASCII(extension_misc::kChromeVoxDirectoryName); |
| 115 if (enabled) { // Load ChromeVox | 113 if (enabled) { // Load ChromeVox |
| (...skipping 26 matching lines...) Expand all Loading... |
| 142 } | 140 } |
| 143 | 141 |
| 144 void ToggleAccessibility(WebUI* login_web_ui) { | 142 void ToggleAccessibility(WebUI* login_web_ui) { |
| 145 bool accessibility_enabled = g_browser_process && | 143 bool accessibility_enabled = g_browser_process && |
| 146 g_browser_process->local_state()->GetBoolean( | 144 g_browser_process->local_state()->GetBoolean( |
| 147 prefs::kAccessibilityEnabled); | 145 prefs::kAccessibilityEnabled); |
| 148 accessibility_enabled = !accessibility_enabled; | 146 accessibility_enabled = !accessibility_enabled; |
| 149 EnableAccessibility(accessibility_enabled, login_web_ui); | 147 EnableAccessibility(accessibility_enabled, login_web_ui); |
| 150 }; | 148 }; |
| 151 | 149 |
| 152 void Speak(const char* speak_str, bool queue, bool interruptible) { | 150 void Speak(const char* utterance) { |
| 153 if (queue || !interruptible) { | 151 UtteranceContinuousParameters params; |
| 154 std::string props = ""; | 152 ExtensionTtsPlatformImpl::GetInstance()->Speak( |
| 155 props.append("enqueue="); | 153 -1, // No utterance ID because we don't need a callback when it finishes. |
| 156 props.append(queue ? "1;" : "0;"); | 154 utterance, |
| 157 props.append("interruptible="); | 155 g_browser_process->GetApplicationLocale(), |
| 158 props.append(interruptible ? "1;" : "0;"); | 156 params); |
| 159 chromeos::DBusThreadManager::Get()->GetSpeechSynthesizerClient()-> | |
| 160 SetSpeakProperties(props); | |
| 161 } | |
| 162 chromeos::DBusThreadManager::Get()->GetSpeechSynthesizerClient()-> | |
| 163 Speak(speak_str); | |
| 164 } | 157 } |
| 165 | 158 |
| 166 | 159 |
| 167 } // namespace accessibility | 160 } // namespace accessibility |
| 168 } // namespace chromeos | 161 } // namespace chromeos |
| OLD | NEW |