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

Side by Side Diff: content/browser/renderer_host/ime_adapter_android.cc

Issue 11343017: Move remaining files in content\browser\renderer_host to content namespace. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix mac Created 8 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/renderer_host/ime_adapter_android.h" 5 #include "content/browser/renderer_host/ime_adapter_android.h"
6 6
7 #include <android/input.h> 7 #include <android/input.h>
8 8
9 #include "base/android/jni_android.h" 9 #include "base/android/jni_android.h"
10 #include "base/android/jni_string.h" 10 #include "base/android/jni_string.h"
11 #include "base/time.h" 11 #include "base/time.h"
12 #include "base/utf_string_conversions.h" 12 #include "base/utf_string_conversions.h"
13 #include "content/browser/renderer_host/render_widget_host_impl.h" 13 #include "content/browser/renderer_host/render_widget_host_impl.h"
14 #include "content/browser/renderer_host/render_widget_host_view_android.h" 14 #include "content/browser/renderer_host/render_widget_host_view_android.h"
15 #include "content/common/view_messages.h" 15 #include "content/common/view_messages.h"
16 #include "content/public/browser/native_web_keyboard_event.h" 16 #include "content/public/browser/native_web_keyboard_event.h"
17 #include "jni/ImeAdapter_jni.h" 17 #include "jni/ImeAdapter_jni.h"
18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositionUnderli ne.h" 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositionUnderli ne.h"
19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
20 20
21 using base::android::AttachCurrentThread; 21 using base::android::AttachCurrentThread;
22 using base::android::ConvertJavaStringToUTF16; 22 using base::android::ConvertJavaStringToUTF16;
23 using content::NativeWebKeyboardEvent;
24 using content::RenderWidgetHostImpl;
25 23
24 namespace content {
26 namespace { 25 namespace {
27 26
28 // Maps a java KeyEvent into a NativeWebKeyboardEvent. 27 // Maps a java KeyEvent into a NativeWebKeyboardEvent.
29 // |java_key_event| is used to maintain a globalref for KeyEvent. 28 // |java_key_event| is used to maintain a globalref for KeyEvent.
30 // |action| will help determine the WebInputEvent type. 29 // |action| will help determine the WebInputEvent type.
31 // type, |modifiers|, |time_ms|, |key_code|, |unicode_char| is used to create 30 // type, |modifiers|, |time_ms|, |key_code|, |unicode_char| is used to create
32 // WebKeyboardEvent. |key_code| is also needed ad need to treat the enter key 31 // WebKeyboardEvent. |key_code| is also needed ad need to treat the enter key
33 // as a key press of character \r. 32 // as a key press of character \r.
34 NativeWebKeyboardEvent NativeWebKeyboardEventFromKeyEvent( 33 NativeWebKeyboardEvent NativeWebKeyboardEventFromKeyEvent(
35 JNIEnv* env, 34 JNIEnv* env,
36 jobject java_key_event, 35 jobject java_key_event,
37 int action, 36 int action,
38 int modifiers, 37 int modifiers,
39 long time_ms, 38 long time_ms,
40 int key_code, 39 int key_code,
41 bool is_system_key, 40 bool is_system_key,
42 int unicode_char) { 41 int unicode_char) {
43 WebKit::WebInputEvent::Type type = WebKit::WebInputEvent::Undefined; 42 WebKit::WebInputEvent::Type type = WebKit::WebInputEvent::Undefined;
44 if (action == AKEY_EVENT_ACTION_DOWN) 43 if (action == AKEY_EVENT_ACTION_DOWN)
45 type = WebKit::WebInputEvent::RawKeyDown; 44 type = WebKit::WebInputEvent::RawKeyDown;
46 else if (action == AKEY_EVENT_ACTION_UP) 45 else if (action == AKEY_EVENT_ACTION_UP)
47 type = WebKit::WebInputEvent::KeyUp; 46 type = WebKit::WebInputEvent::KeyUp;
48 return NativeWebKeyboardEvent(java_key_event, type, modifiers, 47 return NativeWebKeyboardEvent(java_key_event, type, modifiers,
49 time_ms, key_code, unicode_char, is_system_key); 48 time_ms, key_code, unicode_char, is_system_key);
50 } 49 }
51 50
52 } // anonymous namespace 51 } // anonymous namespace
53 52
54 namespace content {
55
56 bool RegisterImeAdapter(JNIEnv* env) { 53 bool RegisterImeAdapter(JNIEnv* env) {
57 if (!RegisterNativesImpl(env)) 54 if (!RegisterNativesImpl(env))
58 return false; 55 return false;
59 56
60 Java_ImeAdapter_initializeWebInputEvents(env, 57 Java_ImeAdapter_initializeWebInputEvents(env,
61 WebKit::WebInputEvent::RawKeyDown, 58 WebKit::WebInputEvent::RawKeyDown,
62 WebKit::WebInputEvent::KeyUp, 59 WebKit::WebInputEvent::KeyUp,
63 WebKit::WebInputEvent::Char, 60 WebKit::WebInputEvent::Char,
64 WebKit::WebInputEvent::ShiftKey, 61 WebKit::WebInputEvent::ShiftKey,
65 WebKit::WebInputEvent::AltKey, 62 WebKit::WebInputEvent::AltKey,
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 void ImeAdapterAndroid::Paste(JNIEnv* env, jobject) { 265 void ImeAdapterAndroid::Paste(JNIEnv* env, jobject) {
269 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From( 266 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(
270 rwhva_->GetRenderWidgetHost()); 267 rwhva_->GetRenderWidgetHost());
271 if (!rwhi) 268 if (!rwhi)
272 return; 269 return;
273 270
274 rwhi->Send(new ViewMsg_Paste(rwhi->GetRoutingID())); 271 rwhi->Send(new ViewMsg_Paste(rwhi->GetRoutingID()));
275 } 272 }
276 273
277 } // namespace content 274 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698