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/utf_string_conversions.h" | 8 #include "base/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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 NOTREACHED(); | 142 NOTREACHED(); |
143 return WebSpeechRecognizerClient::OtherError; | 143 return WebSpeechRecognizerClient::OtherError; |
144 } | 144 } |
145 | 145 |
146 void SpeechRecognitionDispatcher::OnErrorOccurred( | 146 void SpeechRecognitionDispatcher::OnErrorOccurred( |
147 int request_id, const SpeechRecognitionError& error) { | 147 int request_id, const SpeechRecognitionError& error) { |
148 if (error.code == SPEECH_RECOGNITION_ERROR_NO_MATCH) { | 148 if (error.code == SPEECH_RECOGNITION_ERROR_NO_MATCH) { |
149 recognizer_client_->didReceiveNoMatch(GetHandleFromID(request_id), | 149 recognizer_client_->didReceiveNoMatch(GetHandleFromID(request_id), |
150 WebSpeechRecognitionResult()); | 150 WebSpeechRecognitionResult()); |
151 } else { | 151 } else { |
152 recognizer_client_->didReceiveError(GetHandleFromID(request_id), | 152 recognizer_client_->didReceiveError( |
153 WebString(), // TODO(primiano): message? | 153 GetHandleFromID(request_id), |
154 WebKitErrorCode(error.code)); | 154 WebString(), // TODO(primiano): message? |
| 155 WebKitErrorCode(error.code)); |
155 } | 156 } |
156 } | 157 } |
157 | 158 |
158 void SpeechRecognitionDispatcher::OnRecognitionEnded(int request_id) { | 159 void SpeechRecognitionDispatcher::OnRecognitionEnded(int request_id) { |
159 // TODO(tommi): It is possible that the handle isn't found in the array if | 160 // TODO(tommi): It is possible that the handle isn't found in the array if |
160 // the user just refreshed the page. It seems that we then get a notification | 161 // the user just refreshed the page. It seems that we then get a notification |
161 // for the previously loaded instance of the page. | 162 // for the previously loaded instance of the page. |
162 HandleMap::iterator iter = handle_map_.find(request_id); | 163 HandleMap::iterator iter = handle_map_.find(request_id); |
163 if (iter == handle_map_.end()) { | 164 if (iter == handle_map_.end()) { |
164 DLOG(ERROR) << "OnRecognitionEnded called for a handle that doesn't exist"; | 165 DLOG(ERROR) << "OnRecognitionEnded called for a handle that doesn't exist"; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 } | 235 } |
235 | 236 |
236 const WebSpeechRecognitionHandle& SpeechRecognitionDispatcher::GetHandleFromID( | 237 const WebSpeechRecognitionHandle& SpeechRecognitionDispatcher::GetHandleFromID( |
237 int request_id) { | 238 int request_id) { |
238 HandleMap::iterator iter = handle_map_.find(request_id); | 239 HandleMap::iterator iter = handle_map_.find(request_id); |
239 DCHECK(iter != handle_map_.end()); | 240 DCHECK(iter != handle_map_.end()); |
240 return iter->second; | 241 return iter->second; |
241 } | 242 } |
242 | 243 |
243 } // namespace content | 244 } // namespace content |
OLD | NEW |