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" |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 } | 102 } |
103 if (desired_event_types_.size() > 0 && | 103 if (desired_event_types_.size() > 0 && |
104 desired_event_types_.find(event_type_string) == | 104 desired_event_types_.find(event_type_string) == |
105 desired_event_types_.end()) { | 105 desired_event_types_.end()) { |
106 return; | 106 return; |
107 } | 107 } |
108 | 108 |
109 if (src_id_ < 0) | 109 if (src_id_ < 0) |
110 return; | 110 return; |
111 | 111 |
112 DictionaryValue* event = new DictionaryValue(); | 112 DictionaryValue* details = new DictionaryValue(); |
113 if (char_index != kInvalidCharIndex) | 113 if (char_index != kInvalidCharIndex) |
114 event->SetInteger(constants::kCharIndexKey, char_index); | 114 details->SetInteger(constants::kCharIndexKey, char_index); |
115 event->SetString(constants::kEventTypeKey, event_type_string); | 115 details->SetString(constants::kEventTypeKey, event_type_string); |
116 if (event_type == TTS_EVENT_ERROR) { | 116 if (event_type == TTS_EVENT_ERROR) { |
117 event->SetString(constants::kErrorMessageKey, error_message); | 117 details->SetString(constants::kErrorMessageKey, error_message); |
118 } | 118 } |
119 event->SetInteger(constants::kSrcIdKey, src_id_); | 119 details->SetInteger(constants::kSrcIdKey, src_id_); |
120 event->SetBoolean(constants::kIsFinalEventKey, finished_); | 120 details->SetBoolean(constants::kIsFinalEventKey, finished_); |
121 | 121 |
122 scoped_ptr<ListValue> arguments(new ListValue()); | 122 scoped_ptr<ListValue> arguments(new ListValue()); |
123 arguments->Set(0, event); | 123 arguments->Set(0, details); |
124 | 124 |
| 125 scoped_ptr<extensions::Event> event(new extensions::Event( |
| 126 events::kOnEvent, arguments.Pass())); |
| 127 event->restrict_to_profile = profile_; |
| 128 event->event_url = src_url_; |
125 extensions::ExtensionSystem::Get(profile_)->event_router()-> | 129 extensions::ExtensionSystem::Get(profile_)->event_router()-> |
126 DispatchEventToExtension(src_extension_id_, events::kOnEvent, | 130 DispatchEventToExtension(src_extension_id_, event.Pass()); |
127 arguments.Pass(), profile_, src_url_); | |
128 } | 131 } |
129 | 132 |
130 void Utterance::Finish() { | 133 void Utterance::Finish() { |
131 finished_ = true; | 134 finished_ = true; |
132 } | 135 } |
133 | 136 |
134 void Utterance::set_options(const Value* options) { | 137 void Utterance::set_options(const Value* options) { |
135 options_.reset(options->DeepCopy()); | 138 options_.reset(options->DeepCopy()); |
136 } | 139 } |
137 | 140 |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 | 339 |
337 int ExtensionTtsController::QueueSize() { | 340 int ExtensionTtsController::QueueSize() { |
338 return static_cast<int>(utterance_queue_.size()); | 341 return static_cast<int>(utterance_queue_.size()); |
339 } | 342 } |
340 | 343 |
341 ExtensionTtsPlatformImpl* ExtensionTtsController::GetPlatformImpl() { | 344 ExtensionTtsPlatformImpl* ExtensionTtsController::GetPlatformImpl() { |
342 if (!platform_impl_) | 345 if (!platform_impl_) |
343 platform_impl_ = ExtensionTtsPlatformImpl::GetInstance(); | 346 platform_impl_ = ExtensionTtsPlatformImpl::GetInstance(); |
344 return platform_impl_; | 347 return platform_impl_; |
345 } | 348 } |
OLD | NEW |