OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "content/browser/renderer_host/ime_adapter_android.h" | |
6 | |
7 #include "base/android/jni_android.h" | |
8 #include "base/android/jni_string.h" | |
9 #include "content/browser/renderer_host/render_widget_host_impl.h" | |
10 #include "content/browser/renderer_host/render_widget_host_view_android.h" | |
11 #include "content/common/view_messages.h" | |
12 #include "jni/ImeAdapter_jni.h" | |
13 | |
14 bool RegisterImeAdapter(JNIEnv* env) { | |
15 if (!RegisterNativesImpl(env)) { | |
16 return false; | |
17 } | |
18 | |
19 return true; | |
20 } | |
21 | |
22 ImeAdapterAndroid::ImeAdapterAndroid( | |
23 content::RenderWidgetHostViewAndroid* rwhva) | |
qinmin
2012/07/31 19:22:48
ditto
aurimas (slooooooooow)
2012/07/31 21:12:14
Done.
| |
24 : rwhva_(rwhva), | |
25 java_ime_adapter_(NULL) { | |
26 } | |
27 | |
28 ImeAdapterAndroid::~ImeAdapterAndroid() { | |
29 if (java_ime_adapter_) { | |
30 JNIEnv* env = base::android::AttachCurrentThread(); | |
31 Java_ImeAdapter_detach(env, java_ime_adapter_); | |
32 env->DeleteGlobalRef(java_ime_adapter_); | |
33 } | |
34 } | |
35 | |
36 void ImeAdapterAndroid::Unselect(JNIEnv* env, jobject) { | |
37 content::RenderWidgetHostImpl* rwhi = content::RenderWidgetHostImpl::From( | |
38 rwhva_->GetRenderWidgetHost()); | |
39 if (!rwhi) | |
40 return; | |
41 | |
42 rwhi->Send(new ViewMsg_Unselect(rwhi->GetRoutingID())); | |
43 } | |
44 | |
45 void ImeAdapterAndroid::SelectAll(JNIEnv* env, jobject) { | |
46 content::RenderWidgetHostImpl* rwhi = content::RenderWidgetHostImpl::From( | |
47 rwhva_->GetRenderWidgetHost()); | |
48 if (!rwhi) | |
49 return; | |
50 | |
51 rwhi->Send(new ViewMsg_SelectAll(rwhi->GetRoutingID())); | |
52 } | |
53 | |
54 void ImeAdapterAndroid::Cut(JNIEnv* env, jobject) { | |
55 content::RenderWidgetHostImpl* rwhi = content::RenderWidgetHostImpl::From( | |
qinmin
2012/07/31 19:22:48
ditto
aurimas (slooooooooow)
2012/07/31 21:12:14
Done.
| |
56 rwhva_->GetRenderWidgetHost()); | |
57 if (!rwhi) | |
58 return; | |
59 | |
60 rwhi->Send(new ViewMsg_Cut(rwhi->GetRoutingID())); | |
61 } | |
62 | |
63 void ImeAdapterAndroid::Copy(JNIEnv* env, jobject) { | |
64 content::RenderWidgetHostImpl* rwhi = content::RenderWidgetHostImpl::From( | |
65 rwhva_->GetRenderWidgetHost()); | |
66 if (!rwhi) | |
67 return; | |
68 | |
69 rwhi->Send(new ViewMsg_Copy(rwhi->GetRoutingID())); | |
70 } | |
71 | |
72 void ImeAdapterAndroid::Paste(JNIEnv* env, jobject) { | |
73 content::RenderWidgetHostImpl* rwhi = content::RenderWidgetHostImpl::From( | |
qinmin
2012/07/31 19:22:48
ditto
aurimas (slooooooooow)
2012/07/31 21:12:14
Done.
| |
74 rwhva_->GetRenderWidgetHost()); | |
75 if (!rwhi) | |
76 return; | |
77 | |
78 rwhi->Send(new ViewMsg_Paste(rwhi->GetRoutingID())); | |
79 } | |
OLD | NEW |