| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_recognizer_impl_android.h" | 5 #include "content/browser/speech/speech_recognizer_impl_android.h" |
| 6 | 6 |
| 7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
| 8 #include "base/android/jni_array.h" | 8 #include "base/android/jni_array.h" |
| 9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
| 10 #include "base/android/scoped_java_ref.h" | 10 #include "base/android/scoped_java_ref.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind( | 48 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind( |
| 49 &content::SpeechRecognizerImplAndroid::StartRecognitionOnUIThread, this, | 49 &content::SpeechRecognizerImplAndroid::StartRecognitionOnUIThread, this, |
| 50 config.language, config.continuous, config.interim_results)); | 50 config.language, config.continuous, config.interim_results)); |
| 51 } | 51 } |
| 52 | 52 |
| 53 void SpeechRecognizerImplAndroid::StartRecognitionOnUIThread( | 53 void SpeechRecognizerImplAndroid::StartRecognitionOnUIThread( |
| 54 std::string language, bool continuous, bool interim_results) { | 54 std::string language, bool continuous, bool interim_results) { |
| 55 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 55 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 56 JNIEnv* env = AttachCurrentThread(); | 56 JNIEnv* env = AttachCurrentThread(); |
| 57 j_recognition_.Reset(Java_SpeechRecognition_createSpeechRecognition(env, | 57 j_recognition_.Reset(Java_SpeechRecognition_createSpeechRecognition(env, |
| 58 GetApplicationContext(), reinterpret_cast<jint>(this))); | 58 GetApplicationContext(), reinterpret_cast<intptr_t>(this))); |
| 59 Java_SpeechRecognition_startRecognition(env, j_recognition_.obj(), | 59 Java_SpeechRecognition_startRecognition(env, j_recognition_.obj(), |
| 60 ConvertUTF8ToJavaString(env, language).obj(), continuous, | 60 ConvertUTF8ToJavaString(env, language).obj(), continuous, |
| 61 interim_results); | 61 interim_results); |
| 62 } | 62 } |
| 63 | 63 |
| 64 void SpeechRecognizerImplAndroid::AbortRecognition() { | 64 void SpeechRecognizerImplAndroid::AbortRecognition() { |
| 65 if (BrowserThread::CurrentlyOn(BrowserThread::IO)) { | 65 if (BrowserThread::CurrentlyOn(BrowserThread::IO)) { |
| 66 state_ = STATE_IDLE; | 66 state_ = STATE_IDLE; |
| 67 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind( | 67 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind( |
| 68 &content::SpeechRecognizerImplAndroid::AbortRecognition, this)); | 68 &content::SpeechRecognizerImplAndroid::AbortRecognition, this)); |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 state_ = STATE_IDLE; | 197 state_ = STATE_IDLE; |
| 198 listener()->OnRecognitionEnd(session_id()); | 198 listener()->OnRecognitionEnd(session_id()); |
| 199 } | 199 } |
| 200 | 200 |
| 201 // static | 201 // static |
| 202 bool SpeechRecognizerImplAndroid::RegisterSpeechRecognizer(JNIEnv* env) { | 202 bool SpeechRecognizerImplAndroid::RegisterSpeechRecognizer(JNIEnv* env) { |
| 203 return RegisterNativesImpl(env); | 203 return RegisterNativesImpl(env); |
| 204 } | 204 } |
| 205 | 205 |
| 206 } // namespace content | 206 } // namespace content |
| OLD | NEW |