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

Side by Side Diff: chrome/browser/speech/tts_controller.cc

Issue 361363003: Support onvoiceschanged for extension-based tts engines. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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
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/speech/tts_controller.h" 5 #include "chrome/browser/speech/tts_controller.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/float_util.h" 10 #include "base/float_util.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "chrome/browser/browser_process.h" 12 #include "chrome/browser/browser_process.h"
13 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/speech/extension_api/tts_engine_extension_api.h" 14 #include "chrome/browser/speech/extension_api/tts_engine_extension_api.h"
15 #include "chrome/browser/speech/extension_api/tts_extension_api.h" 15 #include "chrome/browser/speech/extension_api/tts_extension_api.h"
16 #include "chrome/browser/speech/tts_engine_extension_observer.h"
17 #include "chrome/browser/speech/tts_engine_extension_observer.h"
16 #include "chrome/browser/speech/tts_platform.h" 18 #include "chrome/browser/speech/tts_platform.h"
17 #include "chrome/common/extensions/api/speech/tts_engine_manifest_handler.h" 19 #include "chrome/common/extensions/api/speech/tts_engine_manifest_handler.h"
18 #include "extensions/browser/extension_system.h" 20 #include "extensions/browser/extension_system.h"
19 #include "extensions/common/extension.h" 21 #include "extensions/common/extension.h"
20 22
21 namespace { 23 namespace {
22 // A value to be used to indicate that there is no char index available. 24 // A value to be used to indicate that there is no char index available.
23 const int kInvalidCharIndex = -1; 25 const int kInvalidCharIndex = -1;
24 26
25 // Given a language/region code of the form 'fr-FR', returns just the basic 27 // Given a language/region code of the form 'fr-FR', returns just the basic
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 SpeakNow(utterance); 151 SpeakNow(utterance);
150 } 152 }
151 } 153 }
152 154
153 void TtsController::SpeakNow(Utterance* utterance) { 155 void TtsController::SpeakNow(Utterance* utterance) {
154 // Ensure we have all built-in voices loaded. This is a no-op if already 156 // Ensure we have all built-in voices loaded. This is a no-op if already
155 // loaded. 157 // loaded.
156 bool loaded_built_in = 158 bool loaded_built_in =
157 GetPlatformImpl()->LoadBuiltInTtsExtension(utterance->profile()); 159 GetPlatformImpl()->LoadBuiltInTtsExtension(utterance->profile());
158 160
161 // Ensure we're observing newly added engines for the given profile.
162 TtsEngineExtensionObserver::GetInstance(utterance->profile());
dmazzoni 2014/07/07 15:37:26 Is there a better place for this? 1) It feels lik
David Tseng 2014/07/08 23:43:31 I've moved this call. Should address some of your
163
159 // Get all available voices and try to find a matching voice. 164 // Get all available voices and try to find a matching voice.
160 std::vector<VoiceData> voices; 165 std::vector<VoiceData> voices;
161 GetVoices(utterance->profile(), &voices); 166 GetVoices(utterance->profile(), &voices);
162 int index = GetMatchingVoice(utterance, voices); 167 int index = GetMatchingVoice(utterance, voices);
163 168
164 VoiceData voice; 169 VoiceData voice;
165 if (index != -1) { 170 if (index != -1) {
166 // Select the matching voice. 171 // Select the matching voice.
167 voice = voices[index]; 172 voice = voices[index];
168 } else { 173 } else {
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 } 443 }
439 444
440 void TtsController::AddVoicesChangedDelegate(VoicesChangedDelegate* delegate) { 445 void TtsController::AddVoicesChangedDelegate(VoicesChangedDelegate* delegate) {
441 voices_changed_delegates_.insert(delegate); 446 voices_changed_delegates_.insert(delegate);
442 } 447 }
443 448
444 void TtsController::RemoveVoicesChangedDelegate( 449 void TtsController::RemoveVoicesChangedDelegate(
445 VoicesChangedDelegate* delegate) { 450 VoicesChangedDelegate* delegate) {
446 voices_changed_delegates_.erase(delegate); 451 voices_changed_delegates_.erase(delegate);
447 } 452 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698