Index: chrome/browser/speech/tts_controller_impl.cc |
diff --git a/chrome/browser/speech/tts_controller_impl.cc b/chrome/browser/speech/tts_controller_impl.cc |
index 9cd26afe6e43ff3230f026948d90f5a573391c88..052eb973b1611e706baf0c3505dfbe5d8f471374 100644 |
--- a/chrome/browser/speech/tts_controller_impl.cc |
+++ b/chrome/browser/speech/tts_controller_impl.cc |
@@ -91,7 +91,7 @@ void Utterance::OnTtsEvent(TtsEventType event_type, |
if (event_delegate_) |
event_delegate_->OnTtsEvent(this, event_type, char_index, error_message); |
if (finished_) |
- event_delegate_.reset(); |
+ event_delegate_ = NULL; |
} |
void Utterance::Finish() { |
@@ -459,6 +459,38 @@ void TtsControllerImpl::RemoveVoicesChangedDelegate( |
voices_changed_delegates_.erase(delegate); |
} |
+void TtsControllerImpl::RemoveUtteranceEventDelegate( |
+ UtteranceEventDelegate* delegate) { |
+ // First clear any pending utterances with this delegate. |
+ std::queue<Utterance*> old_queue = utterance_queue_; |
+ utterance_queue_ = std::queue<Utterance*>(); |
+ while (!old_queue.empty()) { |
+ Utterance* utterance = old_queue.front(); |
+ old_queue.pop(); |
+ if (utterance->event_delegate() != delegate) |
+ utterance_queue_.push(utterance); |
+ else |
+ delete utterance; |
+ } |
+ |
+ if (current_utterance_ && current_utterance_->event_delegate() == delegate) { |
+ current_utterance_->set_event_delegate(NULL); |
+ if (current_utterance_ && !current_utterance_->extension_id().empty()) { |
David Tseng
2014/10/31 22:33:04
Why the redundant check for current_utterance?
dmazzoni
2014/10/31 22:44:22
Fixed.
|
+#if !defined(OS_ANDROID) |
David Tseng
2014/10/31 22:33:04
Can this happen? (i.e. an utterance with an extens
dmazzoni
2014/10/31 22:44:22
No. I copied this from other code where we handle
|
+ if (tts_engine_delegate_) |
+ tts_engine_delegate_->Stop(current_utterance_); |
+#endif |
+ } else { |
+ GetPlatformImpl()->clear_error(); |
David Tseng
2014/10/31 22:33:04
What's the purpose of doing this?
dmazzoni
2014/10/31 22:44:22
We do this before every call to the platform TTS s
|
+ GetPlatformImpl()->StopSpeaking(); |
David Tseng
2014/10/31 22:33:04
Is this behavior part of the web speech spec?I'm c
dmazzoni
2014/10/31 22:44:22
See crbug.com/418806, there are concerns about a r
David Tseng
2014/11/02 19:55:44
Are there any concerns over really long utterances
|
+ } |
+ |
+ FinishCurrentUtterance(); |
+ if (!paused_) |
+ SpeakNextUtterance(); |
+ } |
+} |
+ |
void TtsControllerImpl::SetTtsEngineDelegate( |
TtsEngineDelegate* delegate) { |
tts_engine_delegate_ = delegate; |