Index: chrome/browser/speech/speech_input_manager.cc |
diff --git a/chrome/browser/speech/speech_input_manager.cc b/chrome/browser/speech/speech_input_manager.cc |
index 25f055074bbd4bdaaf948c8b401478f7d555240f..f76775a85bdf305c1efecbf864d86088f367d904 100644 |
--- a/chrome/browser/speech/speech_input_manager.cc |
+++ b/chrome/browser/speech/speech_input_manager.cc |
@@ -102,6 +102,8 @@ class SpeechInputManagerImpl : public SpeechInputManager, |
const std::string& grammar); |
virtual void CancelRecognition(int caller_id); |
virtual void StopRecording(int caller_id); |
+ virtual void CancelAllRequestsWithDelegate( |
+ SpeechInputManagerDelegate* delegate); |
// SpeechRecognizer::Delegate methods. |
virtual void SetRecognitionResult(int caller_id, |
@@ -254,6 +256,20 @@ void SpeechInputManagerImpl::CancelRecognition(int caller_id) { |
bubble_controller_->CloseBubble(caller_id); |
} |
+void SpeechInputManagerImpl::CancelAllRequestsWithDelegate( |
+ SpeechInputManagerDelegate* delegate) { |
+ SpeechRecognizerMap::iterator it = requests_.begin(); |
+ while (it != requests_.end()) { |
+ if (it->second.delegate == delegate) { |
+ CancelRecognition(it->first); |
+ // This map will have very few elements so it is simpler to restart. |
+ it = requests_.begin(); |
+ } else { |
+ ++it; |
+ } |
+ } |
+} |
+ |
void SpeechInputManagerImpl::StopRecording(int caller_id) { |
DCHECK(HasPendingRequest(caller_id)); |
requests_[caller_id].recognizer->StopRecording(); |