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" |
11 #include "base/values.h" | 11 #include "base/values.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_engine_extension_observer.h" |
14 #include "chrome/browser/speech/extension_api/tts_extension_api_constants.h" | 15 #include "chrome/browser/speech/extension_api/tts_extension_api_constants.h" |
15 #include "chrome/browser/speech/tts_controller.h" | 16 #include "chrome/browser/speech/tts_controller.h" |
16 #include "extensions/browser/event_router.h" | 17 #include "extensions/browser/event_router.h" |
17 #include "extensions/browser/extension_function_registry.h" | 18 #include "extensions/browser/extension_function_registry.h" |
18 #include "ui/base/l10n/l10n_util.h" | 19 #include "ui/base/l10n/l10n_util.h" |
19 | 20 |
20 namespace constants = tts_extension_api_constants; | 21 namespace constants = tts_extension_api_constants; |
21 | 22 |
22 namespace events { | 23 namespace events { |
23 const char kOnEvent[] = "tts.onEvent"; | 24 const char kOnEvent[] = "tts.onEvent"; |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 TtsAPI::TtsAPI(content::BrowserContext* context) { | 344 TtsAPI::TtsAPI(content::BrowserContext* context) { |
344 ExtensionFunctionRegistry* registry = | 345 ExtensionFunctionRegistry* registry = |
345 ExtensionFunctionRegistry::GetInstance(); | 346 ExtensionFunctionRegistry::GetInstance(); |
346 registry->RegisterFunction<ExtensionTtsEngineSendTtsEventFunction>(); | 347 registry->RegisterFunction<ExtensionTtsEngineSendTtsEventFunction>(); |
347 registry->RegisterFunction<TtsGetVoicesFunction>(); | 348 registry->RegisterFunction<TtsGetVoicesFunction>(); |
348 registry->RegisterFunction<TtsIsSpeakingFunction>(); | 349 registry->RegisterFunction<TtsIsSpeakingFunction>(); |
349 registry->RegisterFunction<TtsSpeakFunction>(); | 350 registry->RegisterFunction<TtsSpeakFunction>(); |
350 registry->RegisterFunction<TtsStopSpeakingFunction>(); | 351 registry->RegisterFunction<TtsStopSpeakingFunction>(); |
351 registry->RegisterFunction<TtsPauseFunction>(); | 352 registry->RegisterFunction<TtsPauseFunction>(); |
352 registry->RegisterFunction<TtsResumeFunction>(); | 353 registry->RegisterFunction<TtsResumeFunction>(); |
| 354 |
| 355 // Ensure we're observing newly added engines for the given context. |
| 356 TtsEngineExtensionObserver::GetInstance(Profile::FromBrowserContext(context)); |
353 } | 357 } |
354 | 358 |
355 TtsAPI::~TtsAPI() { | 359 TtsAPI::~TtsAPI() { |
356 } | 360 } |
357 | 361 |
358 static base::LazyInstance<BrowserContextKeyedAPIFactory<TtsAPI> > g_factory = | 362 static base::LazyInstance<BrowserContextKeyedAPIFactory<TtsAPI> > g_factory = |
359 LAZY_INSTANCE_INITIALIZER; | 363 LAZY_INSTANCE_INITIALIZER; |
360 | 364 |
361 BrowserContextKeyedAPIFactory<TtsAPI>* TtsAPI::GetFactoryInstance() { | 365 BrowserContextKeyedAPIFactory<TtsAPI>* TtsAPI::GetFactoryInstance() { |
362 return g_factory.Pointer(); | 366 return g_factory.Pointer(); |
363 } | 367 } |
364 | 368 |
365 } // namespace extensions | 369 } // namespace extensions |
OLD | NEW |