OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/android/content_view_core_impl.h" | 5 #include "content/browser/android/content_view_core_impl.h" |
6 | 6 |
7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
8 #include "base/android/jni_array.h" | 8 #include "base/android/jni_array.h" |
9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
10 #include "base/android/scoped_java_ref.h" | 10 #include "base/android/scoped_java_ref.h" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/json/json_writer.h" | 12 #include "base/json/json_writer.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
16 #include "base/values.h" | 16 #include "base/values.h" |
17 #include "cc/layers/layer.h" | 17 #include "cc/layers/layer.h" |
18 #include "cc/output/begin_frame_args.h" | 18 #include "cc/output/begin_frame_args.h" |
19 #include "content/browser/android/content_video_view.h" | 19 #include "content/browser/android/content_video_view.h" |
| 20 #include "content/browser/android/gesture_event_type.h" |
20 #include "content/browser/android/interstitial_page_delegate_android.h" | 21 #include "content/browser/android/interstitial_page_delegate_android.h" |
21 #include "content/browser/android/load_url_params.h" | 22 #include "content/browser/android/load_url_params.h" |
22 #include "content/browser/frame_host/interstitial_page_impl.h" | 23 #include "content/browser/frame_host/interstitial_page_impl.h" |
23 #include "content/browser/frame_host/navigation_controller_impl.h" | 24 #include "content/browser/frame_host/navigation_controller_impl.h" |
24 #include "content/browser/frame_host/navigation_entry_impl.h" | 25 #include "content/browser/frame_host/navigation_entry_impl.h" |
25 #include "content/browser/media/android/browser_media_player_manager.h" | 26 #include "content/browser/media/android/browser_media_player_manager.h" |
26 #include "content/browser/renderer_host/compositor_impl_android.h" | 27 #include "content/browser/renderer_host/compositor_impl_android.h" |
27 #include "content/browser/renderer_host/input/web_input_event_builders_android.h
" | 28 #include "content/browser/renderer_host/input/web_input_event_builders_android.h
" |
28 #include "content/browser/renderer_host/java/java_bound_object.h" | 29 #include "content/browser/renderer_host/java/java_bound_object.h" |
29 #include "content/browser/renderer_host/java/java_bridge_dispatcher_host_manager
.h" | 30 #include "content/browser/renderer_host/java/java_bridge_dispatcher_host_manager
.h" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 // focus (e.g., following a GestureLongPress). | 124 // focus (e.g., following a GestureLongPress). |
124 case WebInputEvent::GestureTapCancel: | 125 case WebInputEvent::GestureTapCancel: |
125 return true; | 126 return true; |
126 default: | 127 default: |
127 break; | 128 break; |
128 } | 129 } |
129 return false; | 130 return false; |
130 } | 131 } |
131 | 132 |
132 int ToContentViewGestureHandlerType(WebInputEvent::Type type) { | 133 int ToContentViewGestureHandlerType(WebInputEvent::Type type) { |
133 // These values should match exactly those in ContentViewGestureHandler. | |
134 enum ContentViewGestureHandlerType { | |
135 GESTURE_SHOW_PRESS = 0, | |
136 GESTURE_DOUBLE_TAP = 1, | |
137 GESTURE_SINGLE_TAP_UP = 2, | |
138 GESTURE_SINGLE_TAP_CONFIRMED = 3, | |
139 GESTURE_SINGLE_TAP_UNCONFIRMED = 4, | |
140 GESTURE_LONG_PRESS = 5, | |
141 GESTURE_SCROLL_START = 6, | |
142 GESTURE_SCROLL_BY = 7, | |
143 GESTURE_SCROLL_END = 8, | |
144 GESTURE_FLING_START = 9, | |
145 GESTURE_FLING_CANCEL = 10, | |
146 GESTURE_PINCH_BEGIN = 11, | |
147 GESTURE_PINCH_BY = 12, | |
148 GESTURE_PINCH_END = 13, | |
149 GESTURE_TAP_CANCEL = 14, | |
150 GESTURE_LONG_TAP = 15, | |
151 GESTURE_TAP_DOWN = 16 | |
152 }; | |
153 switch (type) { | 134 switch (type) { |
154 case WebInputEvent::GestureScrollBegin: | 135 case WebInputEvent::GestureScrollBegin: |
155 return GESTURE_SCROLL_START; | 136 return SCROLL_START; |
156 case WebInputEvent::GestureScrollEnd: | 137 case WebInputEvent::GestureScrollEnd: |
157 return GESTURE_SCROLL_END; | 138 return SCROLL_END; |
158 case WebInputEvent::GestureScrollUpdate: | 139 case WebInputEvent::GestureScrollUpdate: |
159 return GESTURE_SCROLL_BY; | 140 return SCROLL_BY; |
160 case WebInputEvent::GestureFlingStart: | 141 case WebInputEvent::GestureFlingStart: |
161 return GESTURE_FLING_START; | 142 return FLING_START; |
162 case WebInputEvent::GestureFlingCancel: | 143 case WebInputEvent::GestureFlingCancel: |
163 return GESTURE_FLING_CANCEL; | 144 return FLING_CANCEL; |
164 case WebInputEvent::GestureShowPress: | 145 case WebInputEvent::GestureShowPress: |
165 return GESTURE_SHOW_PRESS; | 146 return SHOW_PRESS; |
166 case WebInputEvent::GestureTap: | 147 case WebInputEvent::GestureTap: |
167 return GESTURE_SINGLE_TAP_CONFIRMED; | 148 return SINGLE_TAP_CONFIRMED; |
168 case WebInputEvent::GestureTapUnconfirmed: | 149 case WebInputEvent::GestureTapUnconfirmed: |
169 return GESTURE_SINGLE_TAP_UNCONFIRMED; | 150 return SINGLE_TAP_UNCONFIRMED; |
170 case WebInputEvent::GestureTapDown: | 151 case WebInputEvent::GestureTapDown: |
171 return GESTURE_TAP_DOWN; | 152 return TAP_DOWN; |
172 case WebInputEvent::GestureTapCancel: | 153 case WebInputEvent::GestureTapCancel: |
173 return GESTURE_TAP_CANCEL; | 154 return TAP_CANCEL; |
174 case WebInputEvent::GestureDoubleTap: | 155 case WebInputEvent::GestureDoubleTap: |
175 return GESTURE_DOUBLE_TAP; | 156 return DOUBLE_TAP; |
176 case WebInputEvent::GestureLongPress: | 157 case WebInputEvent::GestureLongPress: |
177 return GESTURE_LONG_PRESS; | 158 return LONG_PRESS; |
178 case WebInputEvent::GestureLongTap: | 159 case WebInputEvent::GestureLongTap: |
179 return GESTURE_LONG_TAP; | 160 return LONG_TAP; |
180 case WebInputEvent::GesturePinchBegin: | 161 case WebInputEvent::GesturePinchBegin: |
181 return GESTURE_PINCH_BEGIN; | 162 return PINCH_BEGIN; |
182 case WebInputEvent::GesturePinchEnd: | 163 case WebInputEvent::GesturePinchEnd: |
183 return GESTURE_PINCH_END; | 164 return PINCH_END; |
184 case WebInputEvent::GesturePinchUpdate: | 165 case WebInputEvent::GesturePinchUpdate: |
185 return GESTURE_PINCH_BY; | 166 return PINCH_BY; |
186 case WebInputEvent::GestureTwoFingerTap: | 167 case WebInputEvent::GestureTwoFingerTap: |
187 case WebInputEvent::GestureScrollUpdateWithoutPropagation: | 168 case WebInputEvent::GestureScrollUpdateWithoutPropagation: |
188 default: | 169 default: |
189 NOTREACHED() << "Invalid source gesture type: " | 170 NOTREACHED() << "Invalid source gesture type: " |
190 << WebInputEventTraits::GetName(type); | 171 << WebInputEventTraits::GetName(type); |
191 return -1; | 172 return -1; |
192 }; | 173 }; |
193 } | 174 } |
194 | 175 |
195 } // namespace | 176 } // namespace |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); | 576 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); |
596 if (j_obj.is_null()) | 577 if (j_obj.is_null()) |
597 return; | 578 return; |
598 | 579 |
599 switch (event.type) { | 580 switch (event.type) { |
600 case WebInputEvent::GestureFlingStart: | 581 case WebInputEvent::GestureFlingStart: |
601 if (ack_result == INPUT_EVENT_ACK_STATE_CONSUMED) { | 582 if (ack_result == INPUT_EVENT_ACK_STATE_CONSUMED) { |
602 Java_ContentViewCore_onFlingStartEventConsumed(env, j_obj.obj(), | 583 Java_ContentViewCore_onFlingStartEventConsumed(env, j_obj.obj(), |
603 event.data.flingStart.velocityX, event.data.flingStart.velocityY); | 584 event.data.flingStart.velocityX, event.data.flingStart.velocityY); |
604 } else { | 585 } else { |
605 // If a scroll ends with a fling, a GESTURE_SCROLL_END is never sent. | 586 // If a scroll ends with a fling, a SCROLL_END event is never sent. |
606 // However, if that fling went unconsumed, we still need to let the | 587 // However, if that fling went unconsumed, we still need to let the |
607 // listeners know that scrolling has ended. | 588 // listeners know that scrolling has ended. |
608 Java_ContentViewCore_onScrollEndEventAck(env, j_obj.obj()); | 589 Java_ContentViewCore_onScrollEndEventAck(env, j_obj.obj()); |
609 } | 590 } |
610 | 591 |
611 if (ack_result == INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS) { | 592 if (ack_result == INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS) { |
612 Java_ContentViewCore_onFlingStartEventHadNoConsumer(env, j_obj.obj(), | 593 Java_ContentViewCore_onFlingStartEventHadNoConsumer(env, j_obj.obj(), |
613 event.data.flingStart.velocityX, event.data.flingStart.velocityY); | 594 event.data.flingStart.velocityX, event.data.flingStart.velocityY); |
614 } | 595 } |
615 break; | 596 break; |
(...skipping 1263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1879 reinterpret_cast<ui::ViewAndroid*>(view_android), | 1860 reinterpret_cast<ui::ViewAndroid*>(view_android), |
1880 reinterpret_cast<ui::WindowAndroid*>(window_android)); | 1861 reinterpret_cast<ui::WindowAndroid*>(window_android)); |
1881 return reinterpret_cast<intptr_t>(view); | 1862 return reinterpret_cast<intptr_t>(view); |
1882 } | 1863 } |
1883 | 1864 |
1884 bool RegisterContentViewCore(JNIEnv* env) { | 1865 bool RegisterContentViewCore(JNIEnv* env) { |
1885 return RegisterNativesImpl(env); | 1866 return RegisterNativesImpl(env); |
1886 } | 1867 } |
1887 | 1868 |
1888 } // namespace content | 1869 } // namespace content |
OLD | NEW |