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

Side by Side Diff: ui/base/touch/touch_device_android.cc

Issue 2231923002: Make GetApplicationContext return a JavaRef. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Also fix not-currently-compiled unit test Created 4 years, 4 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 (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" 7 #include "base/android/context_utils.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "jni/TouchDevice_jni.h" 9 #include "jni/TouchDevice_jni.h"
10 10
11 using base::android::AttachCurrentThread;
12 using base::android::GetApplicationContext;
13
11 namespace ui { 14 namespace ui {
12 15
13 TouchScreensAvailability GetTouchScreensAvailability() { 16 TouchScreensAvailability GetTouchScreensAvailability() {
14 return TouchScreensAvailability::ENABLED; 17 return TouchScreensAvailability::ENABLED;
15 } 18 }
16 19
17 int MaxTouchPoints() { 20 int MaxTouchPoints() {
18 JNIEnv* env = base::android::AttachCurrentThread(); 21 return Java_TouchDevice_maxTouchPoints(AttachCurrentThread(),
19 jobject context = base::android::GetApplicationContext(); 22 GetApplicationContext());
20 jint max_touch_points = Java_TouchDevice_maxTouchPoints(env, context);
21 return static_cast<int>(max_touch_points);
22 } 23 }
23 24
24 int GetAvailablePointerTypes() { 25 int GetAvailablePointerTypes() {
25 JNIEnv* env = base::android::AttachCurrentThread(); 26 return Java_TouchDevice_availablePointerTypes(AttachCurrentThread(),
26 jobject context = base::android::GetApplicationContext(); 27 GetApplicationContext());
27 jint available_pointer_types =
28 Java_TouchDevice_availablePointerTypes(env, context);
29 return static_cast<int>(available_pointer_types);
30 } 28 }
31 29
32 PointerType GetPrimaryPointerType() { 30 PointerType GetPrimaryPointerType() {
33 int available_pointer_types = GetAvailablePointerTypes(); 31 int available_pointer_types = GetAvailablePointerTypes();
34 if (available_pointer_types & POINTER_TYPE_COARSE) 32 if (available_pointer_types & POINTER_TYPE_COARSE)
35 return POINTER_TYPE_COARSE; 33 return POINTER_TYPE_COARSE;
36 if (available_pointer_types & POINTER_TYPE_FINE) 34 if (available_pointer_types & POINTER_TYPE_FINE)
37 return POINTER_TYPE_FINE; 35 return POINTER_TYPE_FINE;
38 DCHECK_EQ(available_pointer_types, POINTER_TYPE_NONE); 36 DCHECK_EQ(available_pointer_types, POINTER_TYPE_NONE);
39 return POINTER_TYPE_NONE; 37 return POINTER_TYPE_NONE;
40 } 38 }
41 39
42 int GetAvailableHoverTypes() { 40 int GetAvailableHoverTypes() {
43 JNIEnv* env = base::android::AttachCurrentThread(); 41 return Java_TouchDevice_availableHoverTypes(AttachCurrentThread(),
44 jobject context = base::android::GetApplicationContext(); 42 GetApplicationContext());
45 jint available_hover_types =
46 Java_TouchDevice_availableHoverTypes(env, context);
47 return static_cast<int>(available_hover_types);
48 } 43 }
49 44
50 HoverType GetPrimaryHoverType() { 45 HoverType GetPrimaryHoverType() {
51 int available_hover_types = GetAvailableHoverTypes(); 46 int available_hover_types = GetAvailableHoverTypes();
52 if (available_hover_types & HOVER_TYPE_ON_DEMAND) 47 if (available_hover_types & HOVER_TYPE_ON_DEMAND)
53 return HOVER_TYPE_ON_DEMAND; 48 return HOVER_TYPE_ON_DEMAND;
54 if (available_hover_types & HOVER_TYPE_HOVER) 49 if (available_hover_types & HOVER_TYPE_HOVER)
55 return HOVER_TYPE_HOVER; 50 return HOVER_TYPE_HOVER;
56 DCHECK_EQ(available_hover_types, HOVER_TYPE_NONE); 51 DCHECK_EQ(available_hover_types, HOVER_TYPE_NONE);
57 return HOVER_TYPE_NONE; 52 return HOVER_TYPE_NONE;
58 } 53 }
59 54
60 } // namespace ui 55 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698