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

Side by Side Diff: services/native_viewport/platform_viewport_android.cc

Issue 1088793003: Expose sky KeyboardService in android mojo_shell (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 8 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 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 "services/native_viewport/platform_viewport_android.h" 5 #include "services/native_viewport/platform_viewport_android.h"
6 6
7 #include <android/input.h> 7 #include <android/input.h>
8 #include <android/native_window_jni.h> 8 #include <android/native_window_jni.h>
9 9
10 #include "base/android/jni_android.h" 10 #include "base/android/jni_android.h"
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 event->pointer_data->radius_major = touch_major; 136 event->pointer_data->radius_major = touch_major;
137 event->pointer_data->radius_minor = touch_minor; 137 event->pointer_data->radius_minor = touch_minor;
138 event->pointer_data->orientation = orientation; 138 event->pointer_data->orientation = orientation;
139 event->pointer_data->horizontal_wheel = h_wheel; 139 event->pointer_data->horizontal_wheel = h_wheel;
140 event->pointer_data->vertical_wheel = v_wheel; 140 event->pointer_data->vertical_wheel = v_wheel;
141 delegate_->OnEvent(event.Pass()); 141 delegate_->OnEvent(event.Pass());
142 142
143 return true; 143 return true;
144 } 144 }
145 145
146 bool PlatformViewportAndroid::KeyEvent(JNIEnv* env,
147 jobject obj,
148 bool pressed,
149 jint key_code,
150 jint unicode_character) {
151 ui::KeyEvent event(pressed ? ui::ET_KEY_PRESSED : ui::ET_KEY_RELEASED,
152 ui::KeyboardCodeFromAndroidKeyCode(key_code), 0);
153 event.set_platform_keycode(key_code);
154 delegate_->OnEvent(mojo::Event::From(event));
155 if (pressed && unicode_character) {
156 ui::KeyEvent char_event(unicode_character,
157 ui::KeyboardCodeFromAndroidKeyCode(key_code), 0);
158 char_event.set_platform_keycode(key_code);
159 delegate_->OnEvent(mojo::Event::From(char_event));
160 }
161 return true;
162 }
163
164 //////////////////////////////////////////////////////////////////////////////// 146 ////////////////////////////////////////////////////////////////////////////////
165 // PlatformViewportAndroid, PlatformViewport implementation: 147 // PlatformViewportAndroid, PlatformViewport implementation:
166 148
167 void PlatformViewportAndroid::Init(const gfx::Rect& bounds) { 149 void PlatformViewportAndroid::Init(const gfx::Rect& bounds) {
168 JNIEnv* env = base::android::AttachCurrentThread(); 150 JNIEnv* env = base::android::AttachCurrentThread();
169 java_platform_viewport_android_ = JavaObjectWeakGlobalRef( 151 java_platform_viewport_android_ = JavaObjectWeakGlobalRef(
170 env, Java_PlatformViewportAndroid_createForActivity( 152 env, Java_PlatformViewportAndroid_createForActivity(
171 env, base::android::GetApplicationContext(), 153 env, base::android::GetApplicationContext(),
172 reinterpret_cast<jlong>(this)).obj()); 154 reinterpret_cast<jlong>(this)).obj());
173 } 155 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 //////////////////////////////////////////////////////////////////////////////// 188 ////////////////////////////////////////////////////////////////////////////////
207 // PlatformViewport, public: 189 // PlatformViewport, public:
208 190
209 // static 191 // static
210 scoped_ptr<PlatformViewport> PlatformViewport::Create(Delegate* delegate) { 192 scoped_ptr<PlatformViewport> PlatformViewport::Create(Delegate* delegate) {
211 return scoped_ptr<PlatformViewport>( 193 return scoped_ptr<PlatformViewport>(
212 new PlatformViewportAndroid(delegate)).Pass(); 194 new PlatformViewportAndroid(delegate)).Pass();
213 } 195 }
214 196
215 } // namespace native_viewport 197 } // namespace native_viewport
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698