| OLD | NEW |
| 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/extension_api/tts_extension_api.h" | 5 #include "chrome/browser/speech/extension_api/tts_extension_api.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 utterance->set_extension_id(voice_extension_id); | 278 utterance->set_extension_id(voice_extension_id); |
| 279 utterance->set_options(options.get()); | 279 utterance->set_options(options.get()); |
| 280 utterance->set_event_delegate( | 280 utterance->set_event_delegate( |
| 281 (new TtsExtensionEventHandler())->AsWeakPtr()); | 281 (new TtsExtensionEventHandler())->AsWeakPtr()); |
| 282 | 282 |
| 283 TtsController* controller = TtsController::GetInstance(); | 283 TtsController* controller = TtsController::GetInstance(); |
| 284 controller->SpeakOrEnqueue(utterance); | 284 controller->SpeakOrEnqueue(utterance); |
| 285 return true; | 285 return true; |
| 286 } | 286 } |
| 287 | 287 |
| 288 bool TtsStopSpeakingFunction::RunImpl() { | 288 bool TtsStopSpeakingFunction::RunSync() { |
| 289 TtsController::GetInstance()->Stop(); | 289 TtsController::GetInstance()->Stop(); |
| 290 return true; | 290 return true; |
| 291 } | 291 } |
| 292 | 292 |
| 293 bool TtsPauseFunction::RunImpl() { | 293 bool TtsPauseFunction::RunSync() { |
| 294 TtsController::GetInstance()->Pause(); | 294 TtsController::GetInstance()->Pause(); |
| 295 return true; | 295 return true; |
| 296 } | 296 } |
| 297 | 297 |
| 298 bool TtsResumeFunction::RunImpl() { | 298 bool TtsResumeFunction::RunSync() { |
| 299 TtsController::GetInstance()->Resume(); | 299 TtsController::GetInstance()->Resume(); |
| 300 return true; | 300 return true; |
| 301 } | 301 } |
| 302 | 302 |
| 303 bool TtsIsSpeakingFunction::RunImpl() { | 303 bool TtsIsSpeakingFunction::RunSync() { |
| 304 SetResult(base::Value::CreateBooleanValue( | 304 SetResult(base::Value::CreateBooleanValue( |
| 305 TtsController::GetInstance()->IsSpeaking())); | 305 TtsController::GetInstance()->IsSpeaking())); |
| 306 return true; | 306 return true; |
| 307 } | 307 } |
| 308 | 308 |
| 309 bool TtsGetVoicesFunction::RunImpl() { | 309 bool TtsGetVoicesFunction::RunSync() { |
| 310 std::vector<VoiceData> voices; | 310 std::vector<VoiceData> voices; |
| 311 TtsController::GetInstance()->GetVoices(GetProfile(), &voices); | 311 TtsController::GetInstance()->GetVoices(GetProfile(), &voices); |
| 312 | 312 |
| 313 scoped_ptr<base::ListValue> result_voices(new base::ListValue()); | 313 scoped_ptr<base::ListValue> result_voices(new base::ListValue()); |
| 314 for (size_t i = 0; i < voices.size(); ++i) { | 314 for (size_t i = 0; i < voices.size(); ++i) { |
| 315 const VoiceData& voice = voices[i]; | 315 const VoiceData& voice = voices[i]; |
| 316 base::DictionaryValue* result_voice = new base::DictionaryValue(); | 316 base::DictionaryValue* result_voice = new base::DictionaryValue(); |
| 317 result_voice->SetString(constants::kVoiceNameKey, voice.name); | 317 result_voice->SetString(constants::kVoiceNameKey, voice.name); |
| 318 result_voice->SetBoolean(constants::kRemoteKey, voice.remote); | 318 result_voice->SetBoolean(constants::kRemoteKey, voice.remote); |
| 319 if (!voice.lang.empty()) | 319 if (!voice.lang.empty()) |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 } | 356 } |
| 357 | 357 |
| 358 static base::LazyInstance<BrowserContextKeyedAPIFactory<TtsAPI> > g_factory = | 358 static base::LazyInstance<BrowserContextKeyedAPIFactory<TtsAPI> > g_factory = |
| 359 LAZY_INSTANCE_INITIALIZER; | 359 LAZY_INSTANCE_INITIALIZER; |
| 360 | 360 |
| 361 BrowserContextKeyedAPIFactory<TtsAPI>* TtsAPI::GetFactoryInstance() { | 361 BrowserContextKeyedAPIFactory<TtsAPI>* TtsAPI::GetFactoryInstance() { |
| 362 return g_factory.Pointer(); | 362 return g_factory.Pointer(); |
| 363 } | 363 } |
| 364 | 364 |
| 365 } // namespace extensions | 365 } // namespace extensions |
| OLD | NEW |