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

Side by Side Diff: chrome/browser/speech/extension_api/tts_extension_api.cc

Issue 12253022: Manifest handler for all keys background-related. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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/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" 16 #include "chrome/common/extensions/api/speech/tts_engine_manifest_handler.h"
17 #include "chrome/common/extensions/extension_manifest_constants.h"
18 #include "ui/base/l10n/l10n_util.h" 17 #include "ui/base/l10n/l10n_util.h"
19 18
20 namespace constants = tts_extension_api_constants; 19 namespace constants = tts_extension_api_constants;
21 20
22 namespace extensions { 21 namespace extensions {
23 22
24 bool TtsSpeakFunction::RunImpl() { 23 bool TtsSpeakFunction::RunImpl() {
25 std::string text; 24 std::string text;
26 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &text)); 25 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &text));
27 if (text.size() > 32768) { 26 if (text.size() > 32768) {
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 SetResult(TtsController::GetInstance()->GetVoices(profile())); 178 SetResult(TtsController::GetInstance()->GetVoices(profile()));
180 return true; 179 return true;
181 } 180 }
182 181
183 // static 182 // static
184 TtsAPI* TtsAPI::Get(Profile* profile) { 183 TtsAPI* TtsAPI::Get(Profile* profile) {
185 return ProfileKeyedAPIFactory<TtsAPI>::GetForProfile(profile); 184 return ProfileKeyedAPIFactory<TtsAPI>::GetForProfile(profile);
186 } 185 }
187 186
188 TtsAPI::TtsAPI(Profile* profile) { 187 TtsAPI::TtsAPI(Profile* profile) {
189 ManifestHandler::Register(extension_manifest_keys::kTtsEngine, 188 (new TtsEngineManifestHandler)->Register();
190 make_linked_ptr(new TtsEngineManifestHandler));
191 ExtensionFunctionRegistry* registry = 189 ExtensionFunctionRegistry* registry =
192 ExtensionFunctionRegistry::GetInstance(); 190 ExtensionFunctionRegistry::GetInstance();
193 registry->RegisterFunction<ExtensionTtsEngineSendTtsEventFunction>(); 191 registry->RegisterFunction<ExtensionTtsEngineSendTtsEventFunction>();
194 registry->RegisterFunction<TtsGetVoicesFunction>(); 192 registry->RegisterFunction<TtsGetVoicesFunction>();
195 registry->RegisterFunction<TtsIsSpeakingFunction>(); 193 registry->RegisterFunction<TtsIsSpeakingFunction>();
196 registry->RegisterFunction<TtsSpeakFunction>(); 194 registry->RegisterFunction<TtsSpeakFunction>();
197 registry->RegisterFunction<TtsStopSpeakingFunction>(); 195 registry->RegisterFunction<TtsStopSpeakingFunction>();
198 } 196 }
199 197
200 TtsAPI::~TtsAPI() { 198 TtsAPI::~TtsAPI() {
201 } 199 }
202 200
203 static base::LazyInstance<ProfileKeyedAPIFactory<TtsAPI> > 201 static base::LazyInstance<ProfileKeyedAPIFactory<TtsAPI> >
204 g_factory = LAZY_INSTANCE_INITIALIZER; 202 g_factory = LAZY_INSTANCE_INITIALIZER;
205 203
206 ProfileKeyedAPIFactory<TtsAPI>* TtsAPI::GetFactoryInstance() { 204 ProfileKeyedAPIFactory<TtsAPI>* TtsAPI::GetFactoryInstance() {
207 return &g_factory.Get(); 205 return &g_factory.Get();
208 } 206 }
209 207
210 } // namespace extensions 208 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698