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/browser/speech/google_streaming_remote_engine.h" | 5 #include "content/browser/speech/google_streaming_remote_engine.h" |
6 | 6 |
| 7 #include <algorithm> |
7 #include <vector> | 8 #include <vector> |
8 | 9 |
9 #include "base/bind.h" | 10 #include "base/bind.h" |
10 #include "base/rand_util.h" | 11 #include "base/rand_util.h" |
11 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
12 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
13 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
14 #include "base/time/time.h" | 15 #include "base/time/time.h" |
15 #include "content/browser/speech/audio_buffer.h" | 16 #include "content/browser/speech/audio_buffer.h" |
16 #include "content/browser/speech/proto/google_streaming_api.pb.h" | 17 #include "content/browser/speech/proto/google_streaming_api.pb.h" |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 } | 336 } |
336 upstream_args.push_back("client=chromium"); | 337 upstream_args.push_back("client=chromium"); |
337 if (!config_.hardware_info.empty()) { | 338 if (!config_.hardware_info.empty()) { |
338 upstream_args.push_back( | 339 upstream_args.push_back( |
339 "xhw=" + net::EscapeQueryParamValue(config_.hardware_info, true)); | 340 "xhw=" + net::EscapeQueryParamValue(config_.hardware_info, true)); |
340 } | 341 } |
341 if (config_.continuous) | 342 if (config_.continuous) |
342 upstream_args.push_back("continuous"); | 343 upstream_args.push_back("continuous"); |
343 if (config_.interim_results) | 344 if (config_.interim_results) |
344 upstream_args.push_back("interim"); | 345 upstream_args.push_back("interim"); |
345 | 346 if (!config_.auth_token.empty() && !config_.auth_scope.empty()) { |
| 347 upstream_args.push_back( |
| 348 "authScope=" + net::EscapeQueryParamValue(config_.auth_scope, true)); |
| 349 upstream_args.push_back( |
| 350 "authToken=" + net::EscapeQueryParamValue(config_.auth_token, true)); |
| 351 } |
346 GURL upstream_url(std::string(kWebServiceBaseUrl) + | 352 GURL upstream_url(std::string(kWebServiceBaseUrl) + |
347 std::string(kUpstreamUrl) + | 353 std::string(kUpstreamUrl) + |
348 JoinString(upstream_args, '&')); | 354 JoinString(upstream_args, '&')); |
349 | 355 |
350 upstream_fetcher_.reset(URLFetcher::Create( | 356 upstream_fetcher_.reset(URLFetcher::Create( |
351 kUpstreamUrlFetcherIdForTesting, upstream_url, URLFetcher::POST, this)); | 357 kUpstreamUrlFetcherIdForTesting, upstream_url, URLFetcher::POST, this)); |
352 upstream_fetcher_->SetChunkedUpload(encoder_->mime_type()); | 358 upstream_fetcher_->SetChunkedUpload(encoder_->mime_type()); |
353 upstream_fetcher_->SetRequestContext(url_context_.get()); | 359 upstream_fetcher_->SetRequestContext(url_context_.get()); |
354 upstream_fetcher_->SetReferrer(config_.origin_url); | 360 upstream_fetcher_->SetReferrer(config_.origin_url); |
355 upstream_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES | | 361 upstream_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES | |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
571 } | 577 } |
572 | 578 |
573 GoogleStreamingRemoteEngine::FSMEventArgs::FSMEventArgs(FSMEvent event_value) | 579 GoogleStreamingRemoteEngine::FSMEventArgs::FSMEventArgs(FSMEvent event_value) |
574 : event(event_value) { | 580 : event(event_value) { |
575 } | 581 } |
576 | 582 |
577 GoogleStreamingRemoteEngine::FSMEventArgs::~FSMEventArgs() { | 583 GoogleStreamingRemoteEngine::FSMEventArgs::~FSMEventArgs() { |
578 } | 584 } |
579 | 585 |
580 } // namespace content | 586 } // namespace content |
OLD | NEW |