Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(546)

Side by Side Diff: chrome/browser/chromeos/accessibility/accessibility_util.cc

Issue 10850018: Allow spoken feedback to be routed to TTS extensions, not just built-in TTS. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/accessibility_util.h" 5 #include "chrome/browser/chromeos/accessibility/accessibility_util.h"
6 6
7 #include <queue> 7 #include <queue>
8 8
9 #include "ash/high_contrast/high_contrast_controller.h" 9 #include "ash/high_contrast/high_contrast_controller.h"
10 #include "ash/magnifier/magnification_controller.h" 10 #include "ash/magnifier/magnification_controller.h"
11 #include "ash/shell.h" 11 #include "ash/shell.h"
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/bind_helpers.h" 13 #include "base/bind_helpers.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "chrome/browser/accessibility/accessibility_extension_api.h" 15 #include "chrome/browser/accessibility/accessibility_extension_api.h"
16 #include "chrome/browser/browser_process.h" 16 #include "chrome/browser/browser_process.h"
17 #include "chrome/browser/extensions/component_loader.h" 17 #include "chrome/browser/extensions/component_loader.h"
18 #include "chrome/browser/extensions/extension_service.h" 18 #include "chrome/browser/extensions/extension_service.h"
19 #include "chrome/browser/extensions/file_reader.h" 19 #include "chrome/browser/extensions/file_reader.h"
20 #include "chrome/browser/prefs/pref_service.h" 20 #include "chrome/browser/prefs/pref_service.h"
21 #include "chrome/browser/profiles/profile.h" 21 #include "chrome/browser/profiles/profile.h"
22 #include "chrome/browser/profiles/profile_manager.h" 22 #include "chrome/browser/profiles/profile_manager.h"
23 #include "chrome/browser/speech/extension_api/tts_extension_api_platform.h" 23 #include "chrome/browser/speech/extension_api/tts_extension_api_controller.h"
24 #include "chrome/common/extensions/extension.h" 24 #include "chrome/common/extensions/extension.h"
25 #include "chrome/common/extensions/extension_messages.h" 25 #include "chrome/common/extensions/extension_messages.h"
26 #include "chrome/common/extensions/extension_resource.h" 26 #include "chrome/common/extensions/extension_resource.h"
27 #include "chrome/common/extensions/user_script.h" 27 #include "chrome/common/extensions/user_script.h"
28 #include "chrome/common/pref_names.h" 28 #include "chrome/common/pref_names.h"
29 #include "content/public/browser/render_view_host.h" 29 #include "content/public/browser/render_view_host.h"
30 #include "content/public/browser/web_contents.h" 30 #include "content/public/browser/web_contents.h"
31 #include "content/public/browser/web_ui.h" 31 #include "content/public/browser/web_ui.h"
32 #include "grit/browser_resources.h" 32 #include "grit/browser_resources.h"
33 #include "grit/generated_resources.h" 33 #include "grit/generated_resources.h"
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 } 190 }
191 191
192 void ToggleSpokenFeedback(content::WebUI* login_web_ui) { 192 void ToggleSpokenFeedback(content::WebUI* login_web_ui) {
193 bool spoken_feedback_enabled = g_browser_process && 193 bool spoken_feedback_enabled = g_browser_process &&
194 g_browser_process->local_state()->GetBoolean( 194 g_browser_process->local_state()->GetBoolean(
195 prefs::kSpokenFeedbackEnabled); 195 prefs::kSpokenFeedbackEnabled);
196 spoken_feedback_enabled = !spoken_feedback_enabled; 196 spoken_feedback_enabled = !spoken_feedback_enabled;
197 EnableSpokenFeedback(spoken_feedback_enabled, login_web_ui); 197 EnableSpokenFeedback(spoken_feedback_enabled, login_web_ui);
198 }; 198 };
199 199
200 void Speak(const std::string& utterance) { 200 void Speak(const std::string& text) {
201 UtteranceContinuousParameters params; 201 UtteranceContinuousParameters params;
202 ExtensionTtsPlatformImpl::GetInstance()->Speak( 202
203 -1, // No utterance ID because we don't need a callback when it finishes. 203 Profile* profile = ProfileManager::GetDefaultProfile();
204 utterance.c_str(), 204 Utterance* utterance = new Utterance(profile);
205 g_browser_process->GetApplicationLocale(), 205 utterance->set_text(text);
206 params); 206 utterance->set_lang(g_browser_process->GetApplicationLocale());
207 utterance->set_continuous_parameters(params);
208 utterance->set_can_enqueue(false);
209 utterance->set_options(new DictionaryValue());
210
211 ExtensionTtsController* controller = ExtensionTtsController::GetInstance();
212 controller->SpeakOrEnqueue(utterance);
207 } 213 }
208 214
209 bool IsSpokenFeedbackEnabled() { 215 bool IsSpokenFeedbackEnabled() {
210 if (!g_browser_process) { 216 if (!g_browser_process) {
211 return false; 217 return false;
212 } 218 }
213 PrefService* prefs = g_browser_process->local_state(); 219 PrefService* prefs = g_browser_process->local_state();
214 bool spoken_feedback_enabled = prefs && 220 bool spoken_feedback_enabled = prefs &&
215 prefs->GetBoolean(prefs::kSpokenFeedbackEnabled); 221 prefs->GetBoolean(prefs::kSpokenFeedbackEnabled);
216 return spoken_feedback_enabled; 222 return spoken_feedback_enabled;
(...skipping 18 matching lines...) Expand all
235 return enabled; 241 return enabled;
236 } 242 }
237 243
238 void MaybeSpeak(const std::string& utterance) { 244 void MaybeSpeak(const std::string& utterance) {
239 if (IsSpokenFeedbackEnabled()) 245 if (IsSpokenFeedbackEnabled())
240 Speak(utterance); 246 Speak(utterance);
241 } 247 }
242 248
243 } // namespace accessibility 249 } // namespace accessibility
244 } // namespace chromeos 250 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698