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

Side by Side Diff: chrome/browser/extensions/extension_tts_api_controller.cc

Issue 7686018: Fix a bug in the TTS extension API where the getVoices function wouldn't... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 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) 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/extensions/extension_tts_api_controller.h" 5 #include "chrome/browser/extensions/extension_tts_api_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"
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 222
223 current_utterance_->OnTtsEvent(event_type, char_index, error_message); 223 current_utterance_->OnTtsEvent(event_type, char_index, error_message);
224 if (current_utterance_->finished()) { 224 if (current_utterance_->finished()) {
225 FinishCurrentUtterance(); 225 FinishCurrentUtterance();
226 SpeakNextUtterance(); 226 SpeakNextUtterance();
227 } 227 }
228 } 228 }
229 229
230 ListValue* ExtensionTtsController::GetVoices(Profile* profile) { 230 ListValue* ExtensionTtsController::GetVoices(Profile* profile) {
231 ListValue* result_voices = new ListValue(); 231 ListValue* result_voices = new ListValue();
232 if (platform_impl_ && platform_impl_->PlatformImplAvailable()) { 232 ExtensionTtsPlatformImpl* platform_impl = GetPlatformImpl();
233 if (platform_impl && platform_impl->PlatformImplAvailable()) {
233 DictionaryValue* result_voice = new DictionaryValue(); 234 DictionaryValue* result_voice = new DictionaryValue();
234 result_voice->SetString( 235 result_voice->SetString(
235 constants::kVoiceNameKey, constants::kNativeVoiceName); 236 constants::kVoiceNameKey, constants::kNativeVoiceName);
236 if (!platform_impl_->gender().empty()) 237 if (!platform_impl->gender().empty())
237 result_voice->SetString(constants::kGenderKey, platform_impl_->gender()); 238 result_voice->SetString(constants::kGenderKey, platform_impl->gender());
238 ListValue* event_types = new ListValue(); 239 ListValue* event_types = new ListValue();
239 240
240 // All platforms must send end events, and cancelled and interrupted 241 // All platforms must send end events, and cancelled and interrupted
241 // events are generated from the controller. 242 // events are generated from the controller.
242 DCHECK(platform_impl_->SendsEvent(TTS_EVENT_END)); 243 DCHECK(platform_impl->SendsEvent(TTS_EVENT_END));
243 event_types->Append(Value::CreateStringValue(constants::kEventTypeEnd)); 244 event_types->Append(Value::CreateStringValue(constants::kEventTypeEnd));
244 event_types->Append(Value::CreateStringValue( 245 event_types->Append(Value::CreateStringValue(
245 constants::kEventTypeCancelled)); 246 constants::kEventTypeCancelled));
246 event_types->Append(Value::CreateStringValue( 247 event_types->Append(Value::CreateStringValue(
247 constants::kEventTypeInterrupted)); 248 constants::kEventTypeInterrupted));
248 249
249 if (platform_impl_->SendsEvent(TTS_EVENT_START)) 250 if (platform_impl->SendsEvent(TTS_EVENT_START))
250 event_types->Append(Value::CreateStringValue(constants::kEventTypeStart)); 251 event_types->Append(Value::CreateStringValue(constants::kEventTypeStart));
251 if (platform_impl_->SendsEvent(TTS_EVENT_WORD)) 252 if (platform_impl->SendsEvent(TTS_EVENT_WORD))
252 event_types->Append(Value::CreateStringValue(constants::kEventTypeWord)); 253 event_types->Append(Value::CreateStringValue(constants::kEventTypeWord));
253 if (platform_impl_->SendsEvent(TTS_EVENT_SENTENCE)) 254 if (platform_impl->SendsEvent(TTS_EVENT_SENTENCE))
254 event_types->Append(Value::CreateStringValue( 255 event_types->Append(Value::CreateStringValue(
255 constants::kEventTypeSentence)); 256 constants::kEventTypeSentence));
256 if (platform_impl_->SendsEvent(TTS_EVENT_MARKER)) 257 if (platform_impl->SendsEvent(TTS_EVENT_MARKER))
257 event_types->Append(Value::CreateStringValue( 258 event_types->Append(Value::CreateStringValue(
258 constants::kEventTypeMarker)); 259 constants::kEventTypeMarker));
259 if (platform_impl_->SendsEvent(TTS_EVENT_ERROR)) 260 if (platform_impl->SendsEvent(TTS_EVENT_ERROR))
260 event_types->Append(Value::CreateStringValue( 261 event_types->Append(Value::CreateStringValue(
261 constants::kEventTypeError)); 262 constants::kEventTypeError));
262 result_voice->Set(constants::kEventTypesKey, event_types); 263 result_voice->Set(constants::kEventTypesKey, event_types);
263 result_voices->Append(result_voice); 264 result_voices->Append(result_voice);
264 } 265 }
265 266
266 GetExtensionVoices(profile, result_voices); 267 GetExtensionVoices(profile, result_voices);
267 268
268 return result_voices; 269 return result_voices;
269 } 270 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 308
308 int ExtensionTtsController::QueueSize() { 309 int ExtensionTtsController::QueueSize() {
309 return static_cast<int>(utterance_queue_.size()); 310 return static_cast<int>(utterance_queue_.size());
310 } 311 }
311 312
312 ExtensionTtsPlatformImpl* ExtensionTtsController::GetPlatformImpl() { 313 ExtensionTtsPlatformImpl* ExtensionTtsController::GetPlatformImpl() {
313 if (!platform_impl_) 314 if (!platform_impl_)
314 platform_impl_ = ExtensionTtsPlatformImpl::GetInstance(); 315 platform_impl_ = ExtensionTtsPlatformImpl::GetInstance();
315 return platform_impl_; 316 return platform_impl_;
316 } 317 }
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