Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #ifndef BLIMP_CLIENT_APP_ANDROID_WEB_INPUT_BOX_H_ | 5 #ifndef BLIMP_CLIENT_APP_ANDROID_WEB_INPUT_BOX_H_ |
| 6 #define BLIMP_CLIENT_APP_ANDROID_WEB_INPUT_BOX_H_ | 6 #define BLIMP_CLIENT_APP_ANDROID_WEB_INPUT_BOX_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/android/jni_android.h" | 10 #include "base/android/jni_android.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "blimp/client/feature/ime_feature.h" | |
| 13 #include "ui/base/ime/text_input_type.h" | |
| 12 | 14 |
| 13 namespace blimp { | 15 namespace blimp { |
| 14 namespace client { | 16 namespace client { |
| 15 | 17 |
| 16 // The native component of org.chromium.blimp.input.WebInputBox. | 18 // The native component of org.chromium.blimp.input.WebInputBox. |
| 17 class WebInputBox { | 19 class WebInputBox : public ImeFeature::ImeFeatureDelegate { |
| 18 public: | 20 public: |
| 19 static bool RegisterJni(JNIEnv* env); | 21 static bool RegisterJni(JNIEnv* env); |
| 20 | 22 |
| 21 WebInputBox(JNIEnv* env, const base::android::JavaParamRef<jobject>& jobj); | 23 WebInputBox(JNIEnv* env, |
| 24 const base::android::JavaParamRef<jobject>& jobj, | |
| 25 ImeFeature* ime_feature); | |
| 22 | 26 |
| 23 // Brings up or hides the IME for user to enter text. | 27 // Brings up IME for user to enter text. |
| 24 void OnImeRequested(bool show); | 28 void OnShowImeRequested(ui::TextInputType input_type, |
| 29 const std::string& text) override; | |
| 30 | |
| 31 // Hides IME. | |
| 32 void OnHideImeRequested() override; | |
| 25 | 33 |
| 26 // Methods called from Java via JNI. | 34 // Methods called from Java via JNI. |
| 27 void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& jobj); | 35 void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& jobj); |
| 28 | 36 |
| 29 // Sends the text entered from IME to the blimp engine | 37 // Sends the text entered from IME to the blimp engine |
| 30 void OnImeTextEntered(JNIEnv* env, | 38 void OnImeTextEntered(JNIEnv* env, |
| 31 const base::android::JavaParamRef<jobject>& jobj, | 39 const base::android::JavaParamRef<jobject>& jobj, |
| 32 const base::android::JavaParamRef<jstring>& text); | 40 const base::android::JavaParamRef<jstring>& text); |
| 33 | 41 |
| 34 private: | 42 private: |
| 35 virtual ~WebInputBox(); | 43 virtual ~WebInputBox(); |
| 36 | 44 |
| 37 // Reference to the Java object which owns this class. | 45 // Reference to the Java object which owns this class. |
| 38 base::android::ScopedJavaGlobalRef<jobject> java_obj_; | 46 base::android::ScopedJavaGlobalRef<jobject> java_obj_; |
| 39 | 47 |
| 48 // A bridge to the network layer which does the work of (de)serializing the | |
| 49 // outgoing and incoming BlimpMessage::IME messages from the engine. Life time | |
| 50 // of |ime_feature_| is managed by the BlimpClientSession which is expected to | |
| 51 // outlive the WebInputBox. | |
|
Wez
2016/03/22 21:43:38
nit: Lifetime comment belongs w/ the constructor,
shaktisahu
2016/03/22 23:45:42
Hmm.. I would prefer to keep it here, since it pro
Wez
2016/03/23 00:10:53
I disagree; the point at which constraints need to
| |
| 52 ImeFeature* ime_feature_; | |
| 53 | |
| 40 DISALLOW_COPY_AND_ASSIGN(WebInputBox); | 54 DISALLOW_COPY_AND_ASSIGN(WebInputBox); |
| 41 }; | 55 }; |
| 42 | 56 |
| 43 } // namespace client | 57 } // namespace client |
| 44 } // namespace blimp | 58 } // namespace blimp |
| 45 | 59 |
| 46 #endif // BLIMP_CLIENT_APP_ANDROID_WEB_INPUT_BOX_H_ | 60 #endif // BLIMP_CLIENT_APP_ANDROID_WEB_INPUT_BOX_H_ |
| OLD | NEW |