| 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/values.h" | 10 #include "base/values.h" |
| 11 #include "chrome/browser/extensions/extension_function_registry.h" | 11 #include "chrome/browser/extensions/extension_function_registry.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/speech/extension_api/tts_engine_extension_api.h" | 13 #include "chrome/browser/speech/extension_api/tts_engine_extension_api.h" |
| 14 #include "chrome/browser/speech/extension_api/tts_extension_api_constants.h" | 14 #include "chrome/browser/speech/extension_api/tts_extension_api_constants.h" |
| 15 #include "chrome/browser/speech/tts_controller.h" | 15 #include "chrome/browser/speech/tts_controller.h" |
| 16 #include "chrome/common/extensions/api/speech/tts_engine_manifest_handler.h" | |
| 17 #include "ui/base/l10n/l10n_util.h" | 16 #include "ui/base/l10n/l10n_util.h" |
| 18 | 17 |
| 19 namespace constants = tts_extension_api_constants; | 18 namespace constants = tts_extension_api_constants; |
| 20 | 19 |
| 21 namespace extensions { | 20 namespace extensions { |
| 22 | 21 |
| 23 bool TtsSpeakFunction::RunImpl() { | 22 bool TtsSpeakFunction::RunImpl() { |
| 24 std::string text; | 23 std::string text; |
| 25 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &text)); | 24 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &text)); |
| 26 if (text.size() > 32768) { | 25 if (text.size() > 32768) { |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 SetResult(TtsController::GetInstance()->GetVoices(profile())); | 177 SetResult(TtsController::GetInstance()->GetVoices(profile())); |
| 179 return true; | 178 return true; |
| 180 } | 179 } |
| 181 | 180 |
| 182 // static | 181 // static |
| 183 TtsAPI* TtsAPI::Get(Profile* profile) { | 182 TtsAPI* TtsAPI::Get(Profile* profile) { |
| 184 return ProfileKeyedAPIFactory<TtsAPI>::GetForProfile(profile); | 183 return ProfileKeyedAPIFactory<TtsAPI>::GetForProfile(profile); |
| 185 } | 184 } |
| 186 | 185 |
| 187 TtsAPI::TtsAPI(Profile* profile) { | 186 TtsAPI::TtsAPI(Profile* profile) { |
| 188 (new TtsEngineManifestHandler)->Register(); | |
| 189 ExtensionFunctionRegistry* registry = | 187 ExtensionFunctionRegistry* registry = |
| 190 ExtensionFunctionRegistry::GetInstance(); | 188 ExtensionFunctionRegistry::GetInstance(); |
| 191 registry->RegisterFunction<ExtensionTtsEngineSendTtsEventFunction>(); | 189 registry->RegisterFunction<ExtensionTtsEngineSendTtsEventFunction>(); |
| 192 registry->RegisterFunction<TtsGetVoicesFunction>(); | 190 registry->RegisterFunction<TtsGetVoicesFunction>(); |
| 193 registry->RegisterFunction<TtsIsSpeakingFunction>(); | 191 registry->RegisterFunction<TtsIsSpeakingFunction>(); |
| 194 registry->RegisterFunction<TtsSpeakFunction>(); | 192 registry->RegisterFunction<TtsSpeakFunction>(); |
| 195 registry->RegisterFunction<TtsStopSpeakingFunction>(); | 193 registry->RegisterFunction<TtsStopSpeakingFunction>(); |
| 196 } | 194 } |
| 197 | 195 |
| 198 TtsAPI::~TtsAPI() { | 196 TtsAPI::~TtsAPI() { |
| 199 } | 197 } |
| 200 | 198 |
| 201 static base::LazyInstance<ProfileKeyedAPIFactory<TtsAPI> > | 199 static base::LazyInstance<ProfileKeyedAPIFactory<TtsAPI> > |
| 202 g_factory = LAZY_INSTANCE_INITIALIZER; | 200 g_factory = LAZY_INSTANCE_INITIALIZER; |
| 203 | 201 |
| 204 ProfileKeyedAPIFactory<TtsAPI>* TtsAPI::GetFactoryInstance() { | 202 ProfileKeyedAPIFactory<TtsAPI>* TtsAPI::GetFactoryInstance() { |
| 205 return &g_factory.Get(); | 203 return &g_factory.Get(); |
| 206 } | 204 } |
| 207 | 205 |
| 208 } // namespace extensions | 206 } // namespace extensions |
| OLD | NEW |