Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3261)

Unified Diff: chrome/browser/speech/tts_controller_impl.cc

Issue 692203002: Stop utterances from a tab when that tab is closed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/speech/tts_controller_impl.h ('k') | chrome/browser/speech/tts_message_filter.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « chrome/browser/speech/tts_controller_impl.h ('k') | chrome/browser/speech/tts_message_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698