diff options
author | tasak@google.com <tasak@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-03 04:18:50 +0000 |
---|---|---|
committer | tasak@google.com <tasak@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-03 04:18:50 +0000 |
commit | 9469fc0d408c2dcbc3e50dfc4f2a0f24da46fdce (patch) | |
tree | da436bcb98ae52609dd0c23bf1034338e6c1757a /chrome/browser/speech/speech_input_extension_manager.cc | |
parent | 054bd9d26eb1f945d4b7c18e4a30c8c5354bcda8 (diff) | |
download | chromium_src-9469fc0d408c2dcbc3e50dfc4f2a0f24da46fdce.zip chromium_src-9469fc0d408c2dcbc3e50dfc4f2a0f24da46fdce.tar.gz chromium_src-9469fc0d408c2dcbc3e50dfc4f2a0f24da46fdce.tar.bz2 |
Revert 170668
Needs to revert this because its WebKit patch was unrolled.
(See r136319, unreviewed, rolling out r136236).
> Update the Speech Api to support array(s) of result items
> instead of a single item at a time.
>
> BUG=143124
> TEST=Covered by content_unittests
>
> Review URL: https://chromiumcodereview.appspot.com/11421103
TBR=tommi@chromium.org
Review URL: https://codereview.chromium.org/11416310
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@170701 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/speech/speech_input_extension_manager.cc')
-rw-r--r-- | chrome/browser/speech/speech_input_extension_manager.cc | 47 |
1 files changed, 21 insertions, 26 deletions
diff --git a/chrome/browser/speech/speech_input_extension_manager.cc b/chrome/browser/speech/speech_input_extension_manager.cc index 2820937..75ee692 100644 --- a/chrome/browser/speech/speech_input_extension_manager.cc +++ b/chrome/browser/speech/speech_input_extension_manager.cc @@ -263,9 +263,9 @@ int SpeechInputExtensionManager::GetRenderProcessIDForExtension( return rph->GetID(); } -void SpeechInputExtensionManager::OnRecognitionResults( +void SpeechInputExtensionManager::OnRecognitionResult( int session_id, - const content::SpeechRecognitionResults& results) { + const content::SpeechRecognitionResult& result) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); DCHECK_EQ(session_id, speech_recognition_session_id_); @@ -275,40 +275,35 @@ void SpeechInputExtensionManager::OnRecognitionResults( ForceStopOnIOThread(); BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, - base::Bind(&SpeechInputExtensionManager::SetRecognitionResultsOnUIThread, - this, results, extension_id)); + base::Bind(&SpeechInputExtensionManager::SetRecognitionResultOnUIThread, + this, result, extension_id)); } -void SpeechInputExtensionManager::SetRecognitionResultsOnUIThread( - const content::SpeechRecognitionResults& results, +void SpeechInputExtensionManager::SetRecognitionResultOnUIThread( + const content::SpeechRecognitionResult& result, const std::string& extension_id) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - content::SpeechRecognitionResults::const_iterator it = results.begin(); - for (; it != results.end(); ++it) { - const content::SpeechRecognitionResult& result = (*it); + scoped_ptr<ListValue> args(new ListValue()); + DictionaryValue* js_event = new DictionaryValue(); + args->Append(js_event); - scoped_ptr<ListValue> args(new ListValue()); - DictionaryValue* js_event = new DictionaryValue(); - args->Append(js_event); - - ListValue* js_hypothesis_array = new ListValue(); - js_event->Set(kHypothesesKey, js_hypothesis_array); + ListValue* js_hypothesis_array = new ListValue(); + js_event->Set(kHypothesesKey, js_hypothesis_array); - for (size_t i = 0; i < result.hypotheses.size(); ++i) { - const SpeechRecognitionHypothesis& hypothesis = result.hypotheses[i]; + for (size_t i = 0; i < result.hypotheses.size(); ++i) { + const SpeechRecognitionHypothesis& hypothesis = result.hypotheses[i]; - DictionaryValue* js_hypothesis_object = new DictionaryValue(); - js_hypothesis_array->Append(js_hypothesis_object); + DictionaryValue* js_hypothesis_object = new DictionaryValue(); + js_hypothesis_array->Append(js_hypothesis_object); - js_hypothesis_object->SetString(kUtteranceKey, - UTF16ToUTF8(hypothesis.utterance)); - js_hypothesis_object->SetDouble(kConfidenceKey, - hypothesis.confidence); - } - - DispatchEventToExtension(extension_id, kOnResultEvent, args.Pass()); + js_hypothesis_object->SetString(kUtteranceKey, + UTF16ToUTF8(hypothesis.utterance)); + js_hypothesis_object->SetDouble(kConfidenceKey, + hypothesis.confidence); } + + DispatchEventToExtension(extension_id, kOnResultEvent, args.Pass()); } void SpeechInputExtensionManager::OnRecognitionStart(int session_id) { |