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_controller.h" | 5 #include "chrome/browser/speech/extension_api/tts_extension_api_controller.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/float_util.h" | 10 #include "base/float_util.h" |
11 #include "base/json/json_writer.h" | 11 #include "base/json/json_writer.h" |
12 #include "base/values.h" | 12 #include "base/values.h" |
13 #include "chrome/browser/extensions/event_router.h" | 13 #include "chrome/browser/extensions/event_router.h" |
| 14 #include "chrome/browser/extensions/extension_system.h" |
14 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
15 #include "chrome/browser/speech/extension_api/tts_extension_api.h" | 16 #include "chrome/browser/speech/extension_api/tts_extension_api.h" |
16 #include "chrome/browser/speech/extension_api/tts_extension_api_constants.h" | 17 #include "chrome/browser/speech/extension_api/tts_extension_api_constants.h" |
17 #include "chrome/browser/speech/extension_api/tts_extension_api_platform.h" | 18 #include "chrome/browser/speech/extension_api/tts_extension_api_platform.h" |
18 #include "chrome/browser/speech/extension_api/tts_engine_extension_api.h" | 19 #include "chrome/browser/speech/extension_api/tts_engine_extension_api.h" |
19 #include "chrome/common/extensions/extension.h" | 20 #include "chrome/common/extensions/extension.h" |
20 | 21 |
21 namespace constants = tts_extension_api_constants; | 22 namespace constants = tts_extension_api_constants; |
22 | 23 |
23 namespace { | 24 namespace { |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 event->SetString(constants::kEventTypeKey, event_type_string); | 115 event->SetString(constants::kEventTypeKey, event_type_string); |
115 if (event_type == TTS_EVENT_ERROR) { | 116 if (event_type == TTS_EVENT_ERROR) { |
116 event->SetString(constants::kErrorMessageKey, error_message); | 117 event->SetString(constants::kErrorMessageKey, error_message); |
117 } | 118 } |
118 event->SetInteger(constants::kSrcIdKey, src_id_); | 119 event->SetInteger(constants::kSrcIdKey, src_id_); |
119 event->SetBoolean(constants::kIsFinalEventKey, finished_); | 120 event->SetBoolean(constants::kIsFinalEventKey, finished_); |
120 | 121 |
121 scoped_ptr<ListValue> arguments(new ListValue()); | 122 scoped_ptr<ListValue> arguments(new ListValue()); |
122 arguments->Set(0, event); | 123 arguments->Set(0, event); |
123 | 124 |
124 profile_->GetExtensionEventRouter()->DispatchEventToExtension( | 125 extensions::ExtensionSystem::Get(profile_)->event_router()-> |
125 src_extension_id_, | 126 DispatchEventToExtension(src_extension_id_, events::kOnEvent, |
126 events::kOnEvent, | 127 arguments.Pass(), profile_, src_url_); |
127 arguments.Pass(), | |
128 profile_, | |
129 src_url_); | |
130 } | 128 } |
131 | 129 |
132 void Utterance::Finish() { | 130 void Utterance::Finish() { |
133 finished_ = true; | 131 finished_ = true; |
134 } | 132 } |
135 | 133 |
136 void Utterance::set_options(const Value* options) { | 134 void Utterance::set_options(const Value* options) { |
137 options_.reset(options->DeepCopy()); | 135 options_.reset(options->DeepCopy()); |
138 } | 136 } |
139 | 137 |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 | 324 |
327 int ExtensionTtsController::QueueSize() { | 325 int ExtensionTtsController::QueueSize() { |
328 return static_cast<int>(utterance_queue_.size()); | 326 return static_cast<int>(utterance_queue_.size()); |
329 } | 327 } |
330 | 328 |
331 ExtensionTtsPlatformImpl* ExtensionTtsController::GetPlatformImpl() { | 329 ExtensionTtsPlatformImpl* ExtensionTtsController::GetPlatformImpl() { |
332 if (!platform_impl_) | 330 if (!platform_impl_) |
333 platform_impl_ = ExtensionTtsPlatformImpl::GetInstance(); | 331 platform_impl_ = ExtensionTtsPlatformImpl::GetInstance(); |
334 return platform_impl_; | 332 return platform_impl_; |
335 } | 333 } |
OLD | NEW |