summaryrefslogtreecommitdiffstats
path: root/content/browser
diff options
context:
space:
mode:
authorgshires@google.com <gshires@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-26 05:08:34 +0000
committergshires@google.com <gshires@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-26 05:08:34 +0000
commit508d103823a657b4fb94ae7f15c33dffa22ab5e7 (patch)
tree86b1f4651719defb84a9a3adf73b33114e634fd1 /content/browser
parent0b4a9c47bad10b4ecb094171d57c4b355dfd7188 (diff)
downloadchromium_src-508d103823a657b4fb94ae7f15c33dffa22ab5e7.zip
chromium_src-508d103823a657b4fb94ae7f15c33dffa22ab5e7.tar.gz
chromium_src-508d103823a657b4fb94ae7f15c33dffa22ab5e7.tar.bz2
Context menu for "Voice recognition options"
Patch from Glen Shires <gshires@google.com> BUG=79991 Test= Review URL: http://codereview.chromium.org/7086005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@94041 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser')
-rw-r--r--content/browser/speech/speech_input_manager.h10
-rw-r--r--content/browser/speech/speech_recognition_request.cc5
-rw-r--r--content/browser/speech/speech_recognition_request.h1
-rw-r--r--content/browser/speech/speech_recognition_request_unittest.cc4
-rw-r--r--content/browser/speech/speech_recognizer.cc6
-rw-r--r--content/browser/speech/speech_recognizer.h2
-rw-r--r--content/browser/speech/speech_recognizer_unittest.cc4
7 files changed, 23 insertions, 9 deletions
diff --git a/content/browser/speech/speech_input_manager.h b/content/browser/speech/speech_input_manager.h
index 342f2c1..43d6c3a 100644
--- a/content/browser/speech/speech_input_manager.h
+++ b/content/browser/speech/speech_input_manager.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -31,6 +31,8 @@ class SpeechInputManager {
virtual ~Delegate() {}
};
+ SpeechInputManager() : censor_results_(true) {}
+
// Invokes the platform provided microphone settings UI in a non-blocking way,
// via the BrowserThread::FILE thread.
static void ShowAudioInputSettings();
@@ -64,6 +66,12 @@ class SpeechInputManager {
virtual void StopRecording(int caller_id) = 0;
virtual void CancelAllRequestsWithDelegate(Delegate* delegate) = 0;
+
+ void set_censor_results(bool censor) { censor_results_ = censor; }
+
+ bool censor_results() { return censor_results_; }
+ private:
+ bool censor_results_;
};
// This typedef is to workaround the issue with certain versions of
diff --git a/content/browser/speech/speech_recognition_request.cc b/content/browser/speech/speech_recognition_request.cc
index 1e9b24e..645e75d 100644
--- a/content/browser/speech/speech_recognition_request.cc
+++ b/content/browser/speech/speech_recognition_request.cc
@@ -19,8 +19,7 @@
namespace {
const char* const kDefaultSpeechRecognitionUrl =
- "https://www.google.com/speech-api/v1/recognize?xjerr=1&client=chromium&"
- "pfilter=2&";
+ "https://www.google.com/speech-api/v1/recognize?xjerr=1&client=chromium&";
const char* const kHypothesesString = "hypotheses";
const char* const kUtteranceString = "utterance";
const char* const kConfidenceString = "confidence";
@@ -123,6 +122,7 @@ SpeechRecognitionRequest::~SpeechRecognitionRequest() {}
void SpeechRecognitionRequest::Start(const std::string& language,
const std::string& grammar,
+ bool censor_results,
const std::string& hardware_info,
const std::string& origin_url,
const std::string& content_type) {
@@ -151,6 +151,7 @@ void SpeechRecognitionRequest::Start(const std::string& language,
if (!hardware_info.empty())
parts.push_back("xhw=" + EscapeQueryParamValue(hardware_info, true));
parts.push_back("maxresults=" + base::IntToString(kMaxResults));
+ parts.push_back(censor_results ? "pfilter=2" : "pfilter=0");
GURL url(std::string(kDefaultSpeechRecognitionUrl) + JoinString(parts, '&'));
diff --git a/content/browser/speech/speech_recognition_request.h b/content/browser/speech/speech_recognition_request.h
index c375b0f..b6701a1 100644
--- a/content/browser/speech/speech_recognition_request.h
+++ b/content/browser/speech/speech_recognition_request.h
@@ -51,6 +51,7 @@ class SpeechRecognitionRequest : public URLFetcher::Delegate {
// previous request has completed.
void Start(const std::string& language,
const std::string& grammar,
+ bool censor_results,
const std::string& hardware_info,
const std::string& origin_url,
const std::string& content_type);
diff --git a/content/browser/speech/speech_recognition_request_unittest.cc b/content/browser/speech/speech_recognition_request_unittest.cc
index 871eb56..bb5e715 100644
--- a/content/browser/speech/speech_recognition_request_unittest.cc
+++ b/content/browser/speech/speech_recognition_request_unittest.cc
@@ -46,8 +46,8 @@ class SpeechRecognitionRequestTest : public SpeechRecognitionRequestDelegate,
void SpeechRecognitionRequestTest::CreateAndTestRequest(
bool success, const std::string& http_response) {
SpeechRecognitionRequest request(NULL, this);
- request.Start(std::string(), std::string(), std::string(), std::string(),
- std::string());
+ request.Start(std::string(), std::string(), false, std::string(),
+ std::string(), std::string());
request.UploadAudioChunk(std::string(" "), true);
TestURLFetcher* fetcher = url_fetcher_factory_.GetFetcherByID(0);
ASSERT_TRUE(fetcher);
diff --git a/content/browser/speech/speech_recognizer.cc b/content/browser/speech/speech_recognizer.cc
index 3c44401..e6d32ee 100644
--- a/content/browser/speech/speech_recognizer.cc
+++ b/content/browser/speech/speech_recognizer.cc
@@ -58,12 +58,14 @@ SpeechRecognizer::SpeechRecognizer(Delegate* delegate,
int caller_id,
const std::string& language,
const std::string& grammar,
+ bool censor_results,
const std::string& hardware_info,
const std::string& origin_url)
: delegate_(delegate),
caller_id_(caller_id),
language_(language),
grammar_(grammar),
+ censor_results_(censor_results),
hardware_info_(hardware_info),
origin_url_(origin_url),
codec_(AudioEncoder::CODEC_FLAC),
@@ -223,8 +225,8 @@ void SpeechRecognizer::HandleOnData(string* data) {
delegate_->DidStartReceivingAudio(caller_id_);
request_.reset(new SpeechRecognitionRequest(
Profile::Deprecated::GetDefaultRequestContext(), this));
- request_->Start(language_, grammar_, hardware_info_, origin_url_,
- encoder_->mime_type());
+ request_->Start(language_, grammar_, censor_results_, hardware_info_,
+ origin_url_, encoder_->mime_type());
}
string encoded_data;
diff --git a/content/browser/speech/speech_recognizer.h b/content/browser/speech/speech_recognizer.h
index f49b3ea..264194d 100644
--- a/content/browser/speech/speech_recognizer.h
+++ b/content/browser/speech/speech_recognizer.h
@@ -82,6 +82,7 @@ class SpeechRecognizer
int caller_id,
const std::string& language,
const std::string& grammar,
+ bool censor_results,
const std::string& hardware_info,
const std::string& origin_url);
virtual ~SpeechRecognizer();
@@ -131,6 +132,7 @@ class SpeechRecognizer
int caller_id_;
std::string language_;
std::string grammar_;
+ bool censor_results_;
std::string hardware_info_;
std::string origin_url_;
diff --git a/content/browser/speech/speech_recognizer_unittest.cc b/content/browser/speech/speech_recognizer_unittest.cc
index af50c18..aefde20 100644
--- a/content/browser/speech/speech_recognizer_unittest.cc
+++ b/content/browser/speech/speech_recognizer_unittest.cc
@@ -25,8 +25,8 @@ class SpeechRecognizerTest : public SpeechRecognizerDelegate,
: io_thread_(BrowserThread::IO, &message_loop_),
ALLOW_THIS_IN_INITIALIZER_LIST(
recognizer_(new SpeechRecognizer(this, 1, std::string(),
- std::string(), std::string(),
- std::string()))),
+ std::string(), false,
+ std::string(), std::string()))),
recording_complete_(false),
recognition_complete_(false),
result_received_(false),