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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 if (char_index >= 0) | 131 if (char_index >= 0) |
132 details->SetInteger(constants::kCharIndexKey, char_index); | 132 details->SetInteger(constants::kCharIndexKey, char_index); |
133 details->SetString(constants::kEventTypeKey, event_type_string); | 133 details->SetString(constants::kEventTypeKey, event_type_string); |
134 if (event_type == TTS_EVENT_ERROR) { | 134 if (event_type == TTS_EVENT_ERROR) { |
135 details->SetString(constants::kErrorMessageKey, error_message); | 135 details->SetString(constants::kErrorMessageKey, error_message); |
136 } | 136 } |
137 details->SetInteger(constants::kSrcIdKey, utterance->src_id()); | 137 details->SetInteger(constants::kSrcIdKey, utterance->src_id()); |
138 details->SetBoolean(constants::kIsFinalEventKey, utterance->finished()); | 138 details->SetBoolean(constants::kIsFinalEventKey, utterance->finished()); |
139 | 139 |
140 std::unique_ptr<base::ListValue> arguments(new base::ListValue()); | 140 std::unique_ptr<base::ListValue> arguments(new base::ListValue()); |
141 arguments->Set(0, details.release()); | 141 arguments->Append(std::move(details)); |
142 | 142 |
143 std::unique_ptr<extensions::Event> event( | 143 std::unique_ptr<extensions::Event> event( |
144 new extensions::Event(::extensions::events::TTS_ON_EVENT, | 144 new extensions::Event(::extensions::events::TTS_ON_EVENT, |
145 ::events::kOnEvent, std::move(arguments))); | 145 ::events::kOnEvent, std::move(arguments))); |
146 event->restrict_to_browser_context = utterance->browser_context(); | 146 event->restrict_to_browser_context = utterance->browser_context(); |
147 event->event_url = utterance->src_url(); | 147 event->event_url = utterance->src_url(); |
148 extensions::EventRouter::Get(utterance->browser_context()) | 148 extensions::EventRouter::Get(utterance->browser_context()) |
149 ->DispatchEventToExtension(src_extension_id_, std::move(event)); | 149 ->DispatchEventToExtension(src_extension_id_, std::move(event)); |
150 | 150 |
151 if (utterance->finished()) | 151 if (utterance->finished()) |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 | 369 |
370 static base::LazyInstance< | 370 static base::LazyInstance< |
371 BrowserContextKeyedAPIFactory<TtsAPI>>::DestructorAtExit g_factory = | 371 BrowserContextKeyedAPIFactory<TtsAPI>>::DestructorAtExit g_factory = |
372 LAZY_INSTANCE_INITIALIZER; | 372 LAZY_INSTANCE_INITIALIZER; |
373 | 373 |
374 BrowserContextKeyedAPIFactory<TtsAPI>* TtsAPI::GetFactoryInstance() { | 374 BrowserContextKeyedAPIFactory<TtsAPI>* TtsAPI::GetFactoryInstance() { |
375 return g_factory.Pointer(); | 375 return g_factory.Pointer(); |
376 } | 376 } |
377 | 377 |
378 } // namespace extensions | 378 } // namespace extensions |
OLD | NEW |