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

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

Issue 2270323004: Add BlimpView to a Chrome tab when Blimp is enabled. (Closed)
Patch Set: Now owned by BlimpContentsViewAndroid and also implemented touch and sizing 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "blimp/client/core/contents/android/blimp_view.h"
6
7 #include "blimp/client/core/contents/blimp_contents_impl.h"
8 #include "jni/BlimpView_jni.h"
9 #include "ui/android/window_android.h"
10 #include "ui/events/android/motion_event_android.h"
11
12 namespace blimp {
13 namespace client {
14
15 // static
16 bool BlimpView::RegisterJni(JNIEnv* env) {
17 return RegisterNativesImpl(env);
18 }
19
20 BlimpView::BlimpView(BlimpContentsImpl* blimp_contents_impl)
21 : blimp_contents_impl_(blimp_contents_impl) {
22 ui::WindowAndroid* window = blimp_contents_impl_->GetNativeWindow();
23
24 JNIEnv* env = base::android::AttachCurrentThread();
25 java_obj_.Reset(env,
26 Java_BlimpView_create(env, reinterpret_cast<intptr_t>(this),
27 window->GetJavaObject())
28 .obj());
29 }
30
31 BlimpView::~BlimpView() {
32 Java_BlimpView_clearNativePtr(base::android::AttachCurrentThread(),
33 java_obj_);
34 }
35
36 base::android::ScopedJavaLocalRef<jobject> BlimpView::GetJavaObject() {
37 return base::android::ScopedJavaLocalRef<jobject>(java_obj_);
38 }
39
40 base::android::ScopedJavaLocalRef<jobject>
41 BlimpView::CreateViewAndroidDelegate() {
42 return Java_BlimpView_createViewAndroidDelegate(
43 base::android::AttachCurrentThread(), java_obj_);
44 }
45
46 void BlimpView::OnSizeChanged(JNIEnv* env,
47 const base::android::JavaParamRef<jobject>& jobj,
48 jint width,
49 jint height,
50 jfloat device_scale_factor_dp_to_px) {
51 blimp_contents_impl_->SetSizeAndScale(gfx::Size(width, height),
52 device_scale_factor_dp_to_px);
53 }
54
55 jboolean BlimpView::OnTouchEvent(
56 JNIEnv* env,
57 const base::android::JavaParamRef<jobject>& obj,
58 const base::android::JavaParamRef<jobject>& motion_event,
59 jlong time_ms,
60 jint android_action,
61 jint pointer_count,
62 jint history_size,
63 jint action_index,
64 jfloat pos_x_0,
65 jfloat pos_y_0,
66 jfloat pos_x_1,
67 jfloat pos_y_1,
68 jint pointer_id_0,
69 jint pointer_id_1,
70 jfloat touch_major_0,
71 jfloat touch_major_1,
72 jfloat touch_minor_0,
73 jfloat touch_minor_1,
74 jfloat orientation_0,
75 jfloat orientation_1,
76 jfloat tilt_0,
77 jfloat tilt_1,
78 jfloat raw_pos_x,
79 jfloat raw_pos_y,
80 jint android_tool_type_0,
81 jint android_tool_type_1,
82 jint android_button_state,
83 jint android_meta_state,
84 jfloat device_scale_factor_dp_to_px) {
85 ui::MotionEventAndroid::Pointer pointer0(
86 pointer_id_0, pos_x_0, pos_y_0, touch_major_0, touch_minor_0,
87 orientation_0, tilt_0, android_tool_type_0);
88 ui::MotionEventAndroid::Pointer pointer1(
89 pointer_id_1, pos_x_1, pos_y_1, touch_major_1, touch_minor_1,
90 orientation_1, tilt_1, android_tool_type_1);
91 ui::MotionEventAndroid event(
92 1.f / device_scale_factor_dp_to_px, env, motion_event, time_ms,
93 android_action, pointer_count, history_size, action_index,
94 android_button_state, android_meta_state, raw_pos_x - pos_x_0,
95 raw_pos_y - pos_y_0, pointer0, pointer1);
96 // TODO(nyquist): Pass the event to the CompositorManager.
97 return false;
98 }
99
100 } // namespace client
101 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698