| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "ui/base/touch/touch_device.h" | 5 #include "ui/base/touch/touch_device.h" |
| 6 | 6 |
| 7 #include "base/android/context_utils.h" | |
| 8 #include "base/android/jni_array.h" | 7 #include "base/android/jni_array.h" |
| 9 #include "base/logging.h" | 8 #include "base/logging.h" |
| 10 #include "jni/TouchDevice_jni.h" | 9 #include "jni/TouchDevice_jni.h" |
| 11 | 10 |
| 12 using base::android::AttachCurrentThread; | 11 using base::android::AttachCurrentThread; |
| 13 using base::android::GetApplicationContext; | |
| 14 | 12 |
| 15 namespace ui { | 13 namespace ui { |
| 16 | 14 |
| 17 TouchScreensAvailability GetTouchScreensAvailability() { | 15 TouchScreensAvailability GetTouchScreensAvailability() { |
| 18 return TouchScreensAvailability::ENABLED; | 16 return TouchScreensAvailability::ENABLED; |
| 19 } | 17 } |
| 20 | 18 |
| 21 int MaxTouchPoints() { | 19 int MaxTouchPoints() { |
| 22 return Java_TouchDevice_maxTouchPoints(AttachCurrentThread(), | 20 return Java_TouchDevice_maxTouchPoints(AttachCurrentThread()); |
| 23 GetApplicationContext()); | |
| 24 } | 21 } |
| 25 | 22 |
| 26 std::pair<int, int> GetAvailablePointerAndHoverTypes() { | 23 std::pair<int, int> GetAvailablePointerAndHoverTypes() { |
| 27 JNIEnv* env = AttachCurrentThread(); | 24 JNIEnv* env = AttachCurrentThread(); |
| 28 std::vector<int> pointer_and_hover_types; | 25 std::vector<int> pointer_and_hover_types; |
| 29 base::android::JavaIntArrayToIntVector( | 26 base::android::JavaIntArrayToIntVector( |
| 30 env, Java_TouchDevice_availablePointerAndHoverTypes( | 27 env, Java_TouchDevice_availablePointerAndHoverTypes(env).obj(), |
| 31 env, GetApplicationContext()) | |
| 32 .obj(), | |
| 33 &pointer_and_hover_types); | 28 &pointer_and_hover_types); |
| 34 DCHECK_EQ(pointer_and_hover_types.size(), 2u); | 29 DCHECK_EQ(pointer_and_hover_types.size(), 2u); |
| 35 return std::make_pair(pointer_and_hover_types[0], pointer_and_hover_types[1]); | 30 return std::make_pair(pointer_and_hover_types[0], pointer_and_hover_types[1]); |
| 36 } | 31 } |
| 37 | 32 |
| 38 PointerType GetPrimaryPointerType(int available_pointer_types) { | 33 PointerType GetPrimaryPointerType(int available_pointer_types) { |
| 39 if (available_pointer_types & POINTER_TYPE_COARSE) | 34 if (available_pointer_types & POINTER_TYPE_COARSE) |
| 40 return POINTER_TYPE_COARSE; | 35 return POINTER_TYPE_COARSE; |
| 41 if (available_pointer_types & POINTER_TYPE_FINE) | 36 if (available_pointer_types & POINTER_TYPE_FINE) |
| 42 return POINTER_TYPE_FINE; | 37 return POINTER_TYPE_FINE; |
| 43 DCHECK_EQ(available_pointer_types, POINTER_TYPE_NONE); | 38 DCHECK_EQ(available_pointer_types, POINTER_TYPE_NONE); |
| 44 return POINTER_TYPE_NONE; | 39 return POINTER_TYPE_NONE; |
| 45 } | 40 } |
| 46 | 41 |
| 47 HoverType GetPrimaryHoverType(int available_hover_types) { | 42 HoverType GetPrimaryHoverType(int available_hover_types) { |
| 48 if (available_hover_types & HOVER_TYPE_NONE) | 43 if (available_hover_types & HOVER_TYPE_NONE) |
| 49 return HOVER_TYPE_NONE; | 44 return HOVER_TYPE_NONE; |
| 50 DCHECK_EQ(available_hover_types, HOVER_TYPE_HOVER); | 45 DCHECK_EQ(available_hover_types, HOVER_TYPE_HOVER); |
| 51 return HOVER_TYPE_HOVER; | 46 return HOVER_TYPE_HOVER; |
| 52 } | 47 } |
| 53 | 48 |
| 54 } // namespace ui | 49 } // namespace ui |
| OLD | NEW |