Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(108)

Side by Side Diff: blimp/client/core/contents/android/ime_helper_dialog.cc

Issue 2393043004: Blimp: IME should submit form with text (Closed)
Patch Set: dtrainor@ comments Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "blimp/client/core/contents/android/ime_helper_dialog.h" 5 #include "blimp/client/core/contents/android/ime_helper_dialog.h"
6 6
7 #include "base/android/jni_string.h" 7 #include "base/android/jni_string.h"
8 #include "base/callback_helpers.h" 8 #include "base/callback_helpers.h"
9 #include "jni/ImeHelperDialog_jni.h" 9 #include "jni/ImeHelperDialog_jni.h"
10 #include "ui/android/window_android.h" 10 #include "ui/android/window_android.h"
(...skipping 11 matching lines...) Expand all
22 java_obj_.Reset(Java_ImeHelperDialog_create( 22 java_obj_.Reset(Java_ImeHelperDialog_create(
23 env, reinterpret_cast<intptr_t>(this), window->GetJavaObject())); 23 env, reinterpret_cast<intptr_t>(this), window->GetJavaObject()));
24 } 24 }
25 25
26 ImeHelperDialog::~ImeHelperDialog() { 26 ImeHelperDialog::~ImeHelperDialog() {
27 Java_ImeHelperDialog_clearNativePtr(base::android::AttachCurrentThread(), 27 Java_ImeHelperDialog_clearNativePtr(base::android::AttachCurrentThread(),
28 java_obj_); 28 java_obj_);
29 } 29 }
30 30
31 void ImeHelperDialog::OnShowImeRequested( 31 void ImeHelperDialog::OnShowImeRequested(
32 ui::TextInputType input_type, 32 const ImeFeature::WebInputRequest& request) {
33 const std::string& text, 33 current_request_ = request;
34 const ImeFeature::ShowImeCallback& callback) {
35 text_submit_callback_ = callback;
36 34
37 JNIEnv* env = base::android::AttachCurrentThread(); 35 JNIEnv* env = base::android::AttachCurrentThread();
38 DCHECK_NE(ui::TEXT_INPUT_TYPE_NONE, input_type); 36 DCHECK_NE(ui::TEXT_INPUT_TYPE_NONE, current_request_.input_type);
39 Java_ImeHelperDialog_onShowImeRequested( 37 Java_ImeHelperDialog_onShowImeRequested(
40 env, java_obj_, input_type, 38 env, java_obj_, current_request_.input_type,
41 base::android::ConvertUTF8ToJavaString(env, text)); 39 base::android::ConvertUTF8ToJavaString(env, current_request_.text));
42 } 40 }
43 41
44 void ImeHelperDialog::OnHideImeRequested() { 42 void ImeHelperDialog::OnHideImeRequested() {
45 JNIEnv* env = base::android::AttachCurrentThread(); 43 JNIEnv* env = base::android::AttachCurrentThread();
46 Java_ImeHelperDialog_onHideImeRequested(env, java_obj_); 44 Java_ImeHelperDialog_onHideImeRequested(env, java_obj_);
47 } 45 }
48 46
49 void ImeHelperDialog::OnImeTextEntered( 47 void ImeHelperDialog::OnImeTextEntered(
50 JNIEnv* env, 48 JNIEnv* env,
51 const base::android::JavaParamRef<jobject>& jobj, 49 const base::android::JavaParamRef<jobject>& jobj,
52 const base::android::JavaParamRef<jstring>& text) { 50 const base::android::JavaParamRef<jstring>& text,
51 jboolean submit) {
53 std::string text_input = base::android::ConvertJavaStringToUTF8(env, text); 52 std::string text_input = base::android::ConvertJavaStringToUTF8(env, text);
54 base::ResetAndReturn(&text_submit_callback_).Run(text_input); 53
54 ImeFeature::WebInputResponse response;
55 response.text = text_input;
56 response.submit = submit;
57
58 base::ResetAndReturn(&current_request_.show_ime_callback).Run(response);
55 } 59 }
56 60
57 } // namespace client 61 } // namespace client
58 } // namespace blimp 62 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698