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_engine_extension_api.h" | 5 #include "chrome/browser/speech/extension_api/tts_engine_extension_api.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 if (options->HasKey(constants::kSrcIdKey)) | 211 if (options->HasKey(constants::kSrcIdKey)) |
212 options->Remove(constants::kSrcIdKey, NULL); | 212 options->Remove(constants::kSrcIdKey, NULL); |
213 if (options->HasKey(constants::kIsFinalEventKey)) | 213 if (options->HasKey(constants::kIsFinalEventKey)) |
214 options->Remove(constants::kIsFinalEventKey, NULL); | 214 options->Remove(constants::kIsFinalEventKey, NULL); |
215 if (options->HasKey(constants::kOnEventKey)) | 215 if (options->HasKey(constants::kOnEventKey)) |
216 options->Remove(constants::kOnEventKey, NULL); | 216 options->Remove(constants::kOnEventKey, NULL); |
217 | 217 |
218 args->Set(1, options); | 218 args->Set(1, options); |
219 args->Set(2, Value::CreateIntegerValue(utterance->id())); | 219 args->Set(2, Value::CreateIntegerValue(utterance->id())); |
220 | 220 |
| 221 scoped_ptr<extensions::Event> event(new extensions::Event( |
| 222 tts_engine_events::kOnSpeak, args.Pass())); |
| 223 event->restrict_to_profile = utterance->profile(); |
221 extensions::ExtensionSystem::Get(utterance->profile())->event_router()-> | 224 extensions::ExtensionSystem::Get(utterance->profile())->event_router()-> |
222 DispatchEventToExtension( | 225 DispatchEventToExtension(utterance->extension_id(), event.Pass()); |
223 extension->id(), | |
224 tts_engine_events::kOnSpeak, | |
225 args.Pass(), | |
226 utterance->profile(), | |
227 GURL()); | |
228 } | 226 } |
229 | 227 |
230 void ExtensionTtsEngineStop(Utterance* utterance) { | 228 void ExtensionTtsEngineStop(Utterance* utterance) { |
231 scoped_ptr<ListValue> args(new ListValue()); | 229 scoped_ptr<ListValue> args(new ListValue()); |
| 230 scoped_ptr<extensions::Event> event(new extensions::Event( |
| 231 tts_engine_events::kOnStop, args.Pass())); |
| 232 event->restrict_to_profile = utterance->profile(); |
232 extensions::ExtensionSystem::Get(utterance->profile())->event_router()-> | 233 extensions::ExtensionSystem::Get(utterance->profile())->event_router()-> |
233 DispatchEventToExtension( | 234 DispatchEventToExtension(utterance->extension_id(), event.Pass()); |
234 utterance->extension_id(), | |
235 tts_engine_events::kOnStop, | |
236 args.Pass(), | |
237 utterance->profile(), | |
238 GURL()); | |
239 } | 235 } |
240 | 236 |
241 bool ExtensionTtsEngineSendTtsEventFunction::RunImpl() { | 237 bool ExtensionTtsEngineSendTtsEventFunction::RunImpl() { |
242 int utterance_id; | 238 int utterance_id; |
243 std::string error_message; | 239 std::string error_message; |
244 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &utterance_id)); | 240 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &utterance_id)); |
245 | 241 |
246 DictionaryValue* event; | 242 DictionaryValue* event; |
247 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(1, &event)); | 243 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(1, &event)); |
248 | 244 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 std::string error_message; | 287 std::string error_message; |
292 event->GetString(constants::kErrorMessageKey, &error_message); | 288 event->GetString(constants::kErrorMessageKey, &error_message); |
293 controller->OnTtsEvent( | 289 controller->OnTtsEvent( |
294 utterance_id, TTS_EVENT_ERROR, char_index, error_message); | 290 utterance_id, TTS_EVENT_ERROR, char_index, error_message); |
295 } else { | 291 } else { |
296 EXTENSION_FUNCTION_VALIDATE(false); | 292 EXTENSION_FUNCTION_VALIDATE(false); |
297 } | 293 } |
298 | 294 |
299 return true; | 295 return true; |
300 } | 296 } |
OLD | NEW |