| OLD | NEW |
| 1 // Copyright (c) 2011 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/browser/speech/speech_recognition_request.h" | 5 #include "content/browser/speech/speech_recognition_request.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
| 10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
| 11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
| 12 #include "base/values.h" | 12 #include "base/values.h" |
| 13 #include "content/common/net/url_fetcher_impl.h" | 13 #include "content/common/net/url_fetcher_impl.h" |
| 14 #include "content/public/common/speech_input_result.h" | 14 #include "content/public/common/speech_recognition_traits.h" |
| 15 #include "net/base/escape.h" | 15 #include "net/base/escape.h" |
| 16 #include "net/base/load_flags.h" | 16 #include "net/base/load_flags.h" |
| 17 #include "net/url_request/url_request_context.h" | 17 #include "net/url_request/url_request_context.h" |
| 18 #include "net/url_request/url_request_context_getter.h" | 18 #include "net/url_request/url_request_context_getter.h" |
| 19 #include "net/url_request/url_request_status.h" | 19 #include "net/url_request/url_request_status.h" |
| 20 | 20 |
| 21 namespace { | 21 namespace { |
| 22 | 22 |
| 23 const char* const kDefaultSpeechRecognitionUrl = | 23 const char* const kDefaultSpeechRecognitionUrl = |
| 24 "https://www.google.com/speech-api/v1/recognize?xjerr=1&client=chromium&"; | 24 "https://www.google.com/speech-api/v1/recognize?xjerr=1&client=chromium&"; |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 if (index < hypotheses_list->GetSize()) { | 128 if (index < hypotheses_list->GetSize()) { |
| 129 result->hypotheses.clear(); | 129 result->hypotheses.clear(); |
| 130 return false; | 130 return false; |
| 131 } | 131 } |
| 132 | 132 |
| 133 return true; | 133 return true; |
| 134 } | 134 } |
| 135 | 135 |
| 136 } // namespace | 136 } // namespace |
| 137 | 137 |
| 138 namespace speech_input { | 138 namespace speech { |
| 139 | 139 |
| 140 int SpeechRecognitionRequest::url_fetcher_id_for_tests = 0; | 140 int SpeechRecognitionRequest::url_fetcher_id_for_tests = 0; |
| 141 | 141 |
| 142 SpeechRecognitionRequest::SpeechRecognitionRequest( | 142 SpeechRecognitionRequest::SpeechRecognitionRequest( |
| 143 net::URLRequestContextGetter* context, Delegate* delegate) | 143 net::URLRequestContextGetter* context, Delegate* delegate) |
| 144 : url_context_(context), | 144 : url_context_(context), |
| 145 delegate_(delegate) { | 145 delegate_(delegate) { |
| 146 DCHECK(delegate); | 146 DCHECK(delegate); |
| 147 } | 147 } |
| 148 | 148 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 !source->GetResponseAsString(&data) || | 217 !source->GetResponseAsString(&data) || |
| 218 !ParseServerResponse(data, &result)) { | 218 !ParseServerResponse(data, &result)) { |
| 219 result.error = content::SPEECH_INPUT_ERROR_NETWORK; | 219 result.error = content::SPEECH_INPUT_ERROR_NETWORK; |
| 220 } | 220 } |
| 221 | 221 |
| 222 DVLOG(1) << "SpeechRecognitionRequest: Invoking delegate with result."; | 222 DVLOG(1) << "SpeechRecognitionRequest: Invoking delegate with result."; |
| 223 url_fetcher_.reset(); | 223 url_fetcher_.reset(); |
| 224 delegate_->SetRecognitionResult(result); | 224 delegate_->SetRecognitionResult(result); |
| 225 } | 225 } |
| 226 | 226 |
| 227 } // namespace speech_input | 227 } // namespace speech |
| OLD | NEW |