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

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

Issue 2320923002: Add a full Blimp integration test. (Closed)
Patch Set: Fix build break with chrome embedder Created 4 years, 3 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/blimp_view.h" 5 #include "blimp/client/core/contents/android/blimp_view.h"
6 6
7 #include "blimp/client/core/compositor/blimp_compositor_manager.h" 7 #include "blimp/client/core/compositor/blimp_compositor_manager.h"
8 #include "blimp/client/core/contents/blimp_contents_impl.h" 8 #include "blimp/client/core/contents/blimp_contents_impl.h"
9 #include "jni/BlimpView_jni.h" 9 #include "jni/BlimpView_jni.h"
10 #include "ui/android/window_android.h" 10 #include "ui/android/window_android.h"
11 #include "ui/events/android/motion_event_android.h" 11 #include "ui/events/android/motion_event_android.h"
12 12
13 namespace blimp { 13 namespace blimp {
14 namespace client { 14 namespace client {
15 15
16 // static 16 // static
17 bool BlimpView::RegisterJni(JNIEnv* env) { 17 bool BlimpView::RegisterJni(JNIEnv* env) {
18 return RegisterNativesImpl(env); 18 return RegisterNativesImpl(env);
19 } 19 }
20 20
21 BlimpView::BlimpView(BlimpContentsImpl* blimp_contents_impl) 21 BlimpView::BlimpView(ui::WindowAndroid* window,
22 : blimp_contents_impl_(blimp_contents_impl) { 22 BlimpContentsViewImpl* blimp_contents_view)
23 ui::WindowAndroid* window = blimp_contents_impl_->GetNativeWindow(); 23 : blimp_contents_view_(blimp_contents_view) {
24
25 JNIEnv* env = base::android::AttachCurrentThread(); 24 JNIEnv* env = base::android::AttachCurrentThread();
26 java_obj_.Reset(env, 25 java_obj_.Reset(env,
27 Java_BlimpView_create(env, reinterpret_cast<intptr_t>(this), 26 Java_BlimpView_create(env, reinterpret_cast<intptr_t>(this),
28 window->GetJavaObject()) 27 window->GetJavaObject())
29 .obj()); 28 .obj());
30 } 29 }
31 30
32 BlimpView::~BlimpView() { 31 BlimpView::~BlimpView() {
33 Java_BlimpView_clearNativePtr(base::android::AttachCurrentThread(), 32 Java_BlimpView_clearNativePtr(base::android::AttachCurrentThread(),
34 java_obj_); 33 java_obj_);
35 } 34 }
36 35
37 base::android::ScopedJavaLocalRef<jobject> BlimpView::GetJavaObject() { 36 base::android::ScopedJavaLocalRef<jobject> BlimpView::GetJavaObject() {
38 return base::android::ScopedJavaLocalRef<jobject>(java_obj_); 37 return base::android::ScopedJavaLocalRef<jobject>(java_obj_);
39 } 38 }
40 39
41 base::android::ScopedJavaLocalRef<jobject> 40 base::android::ScopedJavaLocalRef<jobject>
42 BlimpView::CreateViewAndroidDelegate() { 41 BlimpView::CreateViewAndroidDelegate() {
43 return Java_BlimpView_createViewAndroidDelegate( 42 return Java_BlimpView_createViewAndroidDelegate(
44 base::android::AttachCurrentThread(), java_obj_); 43 base::android::AttachCurrentThread(), java_obj_);
45 } 44 }
46 45
47 void BlimpView::OnSizeChanged(JNIEnv* env, 46 void BlimpView::OnSizeChanged(JNIEnv* env,
48 const base::android::JavaParamRef<jobject>& jobj, 47 const base::android::JavaParamRef<jobject>& jobj,
49 jint width, 48 jint width,
50 jint height, 49 jint height,
51 jfloat device_scale_factor_dp_to_px) { 50 jfloat device_scale_factor_dp_to_px) {
52 blimp_contents_impl_->SetSizeAndScale(gfx::Size(width, height), 51 blimp_contents_view_->SetSizeAndScale(gfx::Size(width, height),
53 device_scale_factor_dp_to_px); 52 device_scale_factor_dp_to_px);
54 } 53 }
55 54
56 jboolean BlimpView::OnTouchEvent( 55 jboolean BlimpView::OnTouchEvent(
57 JNIEnv* env, 56 JNIEnv* env,
58 const base::android::JavaParamRef<jobject>& obj, 57 const base::android::JavaParamRef<jobject>& obj,
59 const base::android::JavaParamRef<jobject>& motion_event, 58 const base::android::JavaParamRef<jobject>& motion_event,
60 jlong time_ms, 59 jlong time_ms,
61 jint android_action, 60 jint android_action,
62 jint pointer_count, 61 jint pointer_count,
(...skipping 24 matching lines...) Expand all
87 pointer_id_0, pos_x_0, pos_y_0, touch_major_0, touch_minor_0, 86 pointer_id_0, pos_x_0, pos_y_0, touch_major_0, touch_minor_0,
88 orientation_0, tilt_0, android_tool_type_0); 87 orientation_0, tilt_0, android_tool_type_0);
89 ui::MotionEventAndroid::Pointer pointer1( 88 ui::MotionEventAndroid::Pointer pointer1(
90 pointer_id_1, pos_x_1, pos_y_1, touch_major_1, touch_minor_1, 89 pointer_id_1, pos_x_1, pos_y_1, touch_major_1, touch_minor_1,
91 orientation_1, tilt_1, android_tool_type_1); 90 orientation_1, tilt_1, android_tool_type_1);
92 ui::MotionEventAndroid event( 91 ui::MotionEventAndroid event(
93 1.f / device_scale_factor_dp_to_px, env, motion_event, time_ms, 92 1.f / device_scale_factor_dp_to_px, env, motion_event, time_ms,
94 android_action, pointer_count, history_size, action_index, 93 android_action, pointer_count, history_size, action_index,
95 android_button_state, android_meta_state, raw_pos_x - pos_x_0, 94 android_button_state, android_meta_state, raw_pos_x - pos_x_0,
96 raw_pos_y - pos_y_0, pointer0, pointer1); 95 raw_pos_y - pos_y_0, pointer0, pointer1);
97 return blimp_contents_impl_->compositor_manager()->OnTouchEvent(event); 96 return blimp_contents_view_->OnTouchEvent(event);
98 } 97 }
99 98
100 } // namespace client 99 } // namespace client
101 } // namespace blimp 100 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698