| 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 "content/renderer/speech_recognition_dispatcher.h" | 5 #include "content/renderer/speech_recognition_dispatcher.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "content/common/speech_recognition_messages.h" | 9 #include "content/common/speech_recognition_messages.h" |
| 10 #include "content/renderer/render_view_impl.h" | 10 #include "content/renderer/render_view_impl.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 RenderViewImpl* render_view) | 29 RenderViewImpl* render_view) |
| 30 : RenderViewObserver(render_view), | 30 : RenderViewObserver(render_view), |
| 31 recognizer_client_(NULL), | 31 recognizer_client_(NULL), |
| 32 next_id_(1) { | 32 next_id_(1) { |
| 33 } | 33 } |
| 34 | 34 |
| 35 SpeechRecognitionDispatcher::~SpeechRecognitionDispatcher() { | 35 SpeechRecognitionDispatcher::~SpeechRecognitionDispatcher() { |
| 36 } | 36 } |
| 37 | 37 |
| 38 void SpeechRecognitionDispatcher::AbortAllRecognitions() { | 38 void SpeechRecognitionDispatcher::AbortAllRecognitions() { |
| 39 for (HandleMap::iterator iter = handle_map_.begin(); | 39 Send(new SpeechRecognitionHostMsg_AbortAllRequest( |
| 40 iter != handle_map_.end(); | 40 routing_id())); |
| 41 ++iter) { | |
| 42 // OnEnd event will be sent to the SpeechRecognition object later. | |
| 43 abort(iter->second, recognizer_client_); | |
| 44 } | |
| 45 } | 41 } |
| 46 | 42 |
| 47 bool SpeechRecognitionDispatcher::OnMessageReceived( | 43 bool SpeechRecognitionDispatcher::OnMessageReceived( |
| 48 const IPC::Message& message) { | 44 const IPC::Message& message) { |
| 49 bool handled = true; | 45 bool handled = true; |
| 50 IPC_BEGIN_MESSAGE_MAP(SpeechRecognitionDispatcher, message) | 46 IPC_BEGIN_MESSAGE_MAP(SpeechRecognitionDispatcher, message) |
| 51 IPC_MESSAGE_HANDLER(SpeechRecognitionMsg_Started, OnRecognitionStarted) | 47 IPC_MESSAGE_HANDLER(SpeechRecognitionMsg_Started, OnRecognitionStarted) |
| 52 IPC_MESSAGE_HANDLER(SpeechRecognitionMsg_AudioStarted, OnAudioStarted) | 48 IPC_MESSAGE_HANDLER(SpeechRecognitionMsg_AudioStarted, OnAudioStarted) |
| 53 IPC_MESSAGE_HANDLER(SpeechRecognitionMsg_SoundStarted, OnSoundStarted) | 49 IPC_MESSAGE_HANDLER(SpeechRecognitionMsg_SoundStarted, OnSoundStarted) |
| 54 IPC_MESSAGE_HANDLER(SpeechRecognitionMsg_SoundEnded, OnSoundEnded) | 50 IPC_MESSAGE_HANDLER(SpeechRecognitionMsg_SoundEnded, OnSoundEnded) |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 } | 240 } |
| 245 | 241 |
| 246 const WebSpeechRecognitionHandle& SpeechRecognitionDispatcher::GetHandleFromID( | 242 const WebSpeechRecognitionHandle& SpeechRecognitionDispatcher::GetHandleFromID( |
| 247 int request_id) { | 243 int request_id) { |
| 248 HandleMap::iterator iter = handle_map_.find(request_id); | 244 HandleMap::iterator iter = handle_map_.find(request_id); |
| 249 DCHECK(iter != handle_map_.end()); | 245 DCHECK(iter != handle_map_.end()); |
| 250 return iter->second; | 246 return iter->second; |
| 251 } | 247 } |
| 252 | 248 |
| 253 } // namespace content | 249 } // namespace content |
| OLD | NEW |