| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/content_url_request_user_data.h" |
| 14 #include "content/public/common/speech_input_result.h" | 15 #include "content/public/common/speech_input_result.h" |
| 15 #include "net/base/escape.h" | 16 #include "net/base/escape.h" |
| 16 #include "net/base/load_flags.h" | 17 #include "net/base/load_flags.h" |
| 17 #include "net/url_request/url_request_context.h" | 18 #include "net/url_request/url_request_context.h" |
| 18 #include "net/url_request/url_request_context_getter.h" | 19 #include "net/url_request/url_request_context_getter.h" |
| 19 #include "net/url_request/url_request_status.h" | 20 #include "net/url_request/url_request_status.h" |
| 20 | 21 |
| 21 namespace { | 22 namespace { |
| 22 | 23 |
| 23 const char* const kDefaultSpeechRecognitionUrl = | 24 const char* const kDefaultSpeechRecognitionUrl = |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 parts.push_back(filter_profanities ? "pfilter=2" : "pfilter=0"); | 183 parts.push_back(filter_profanities ? "pfilter=2" : "pfilter=0"); |
| 183 | 184 |
| 184 GURL url(std::string(kDefaultSpeechRecognitionUrl) + JoinString(parts, '&')); | 185 GURL url(std::string(kDefaultSpeechRecognitionUrl) + JoinString(parts, '&')); |
| 185 | 186 |
| 186 url_fetcher_.reset(URLFetcherImpl::Create(url_fetcher_id_for_tests, | 187 url_fetcher_.reset(URLFetcherImpl::Create(url_fetcher_id_for_tests, |
| 187 url, | 188 url, |
| 188 URLFetcherImpl::POST, | 189 URLFetcherImpl::POST, |
| 189 this)); | 190 this)); |
| 190 url_fetcher_->SetChunkedUpload(content_type); | 191 url_fetcher_->SetChunkedUpload(content_type); |
| 191 url_fetcher_->SetRequestContext(url_context_); | 192 url_fetcher_->SetRequestContext(url_context_); |
| 193 // No user data, as the request will be cookie-less. |
| 194 url_fetcher_->SetContentURLRequestUserData( |
| 195 new content::ContentURLRequestUserData()); |
| 192 url_fetcher_->SetReferrer(origin_url); | 196 url_fetcher_->SetReferrer(origin_url); |
| 193 | 197 |
| 194 // The speech recognition API does not require user identification as part | 198 // The speech recognition API does not require user identification as part |
| 195 // of requests, so we don't send cookies or auth data for these requests to | 199 // of requests, so we don't send cookies or auth data for these requests to |
| 196 // prevent any accidental connection between users who are logged into the | 200 // prevent any accidental connection between users who are logged into the |
| 197 // domain for other services (e.g. bookmark sync) with the speech requests. | 201 // domain for other services (e.g. bookmark sync) with the speech requests. |
| 198 url_fetcher_->SetLoadFlags( | 202 url_fetcher_->SetLoadFlags( |
| 199 net::LOAD_DO_NOT_SAVE_COOKIES | net::LOAD_DO_NOT_SEND_COOKIES | | 203 net::LOAD_DO_NOT_SAVE_COOKIES | net::LOAD_DO_NOT_SEND_COOKIES | |
| 200 net::LOAD_DO_NOT_SEND_AUTH_DATA); | 204 net::LOAD_DO_NOT_SEND_AUTH_DATA); |
| 201 url_fetcher_->Start(); | 205 url_fetcher_->Start(); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 218 !ParseServerResponse(data, &result)) { | 222 !ParseServerResponse(data, &result)) { |
| 219 result.error = content::SPEECH_INPUT_ERROR_NETWORK; | 223 result.error = content::SPEECH_INPUT_ERROR_NETWORK; |
| 220 } | 224 } |
| 221 | 225 |
| 222 DVLOG(1) << "SpeechRecognitionRequest: Invoking delegate with result."; | 226 DVLOG(1) << "SpeechRecognitionRequest: Invoking delegate with result."; |
| 223 url_fetcher_.reset(); | 227 url_fetcher_.reset(); |
| 224 delegate_->SetRecognitionResult(result); | 228 delegate_->SetRecognitionResult(result); |
| 225 } | 229 } |
| 226 | 230 |
| 227 } // namespace speech_input | 231 } // namespace speech_input |
| OLD | NEW |