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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: ui/base/touch/touch_device_android.cc
diff --git a/ui/base/touch/touch_device_android.cc b/ui/base/touch/touch_device_android.cc
index ff44f8c84819f66c45ce638743e13ac68476335a..0924783dffa7549c51ff514274e23593e9dc5803 100644
--- a/ui/base/touch/touch_device_android.cc
+++ b/ui/base/touch/touch_device_android.cc
@@ -8,6 +8,9 @@
#include "base/logging.h"
#include "jni/TouchDevice_jni.h"
+using base::android::AttachCurrentThread;
+using base::android::GetApplicationContext;
+
namespace ui {
TouchScreensAvailability GetTouchScreensAvailability() {
@@ -15,18 +18,13 @@ TouchScreensAvailability GetTouchScreensAvailability() {
}
int MaxTouchPoints() {
- JNIEnv* env = base::android::AttachCurrentThread();
- jobject context = base::android::GetApplicationContext();
- jint max_touch_points = Java_TouchDevice_maxTouchPoints(env, context);
- return static_cast<int>(max_touch_points);
+ return Java_TouchDevice_maxTouchPoints(AttachCurrentThread(),
+ GetApplicationContext());
}
int GetAvailablePointerTypes() {
- JNIEnv* env = base::android::AttachCurrentThread();
- jobject context = base::android::GetApplicationContext();
- jint available_pointer_types =
- Java_TouchDevice_availablePointerTypes(env, context);
- return static_cast<int>(available_pointer_types);
+ return Java_TouchDevice_availablePointerTypes(AttachCurrentThread(),
+ GetApplicationContext());
}
PointerType GetPrimaryPointerType() {
@@ -40,11 +38,8 @@ PointerType GetPrimaryPointerType() {
}
int GetAvailableHoverTypes() {
- JNIEnv* env = base::android::AttachCurrentThread();
- jobject context = base::android::GetApplicationContext();
- jint available_hover_types =
- Java_TouchDevice_availableHoverTypes(env, context);
- return static_cast<int>(available_hover_types);
+ return Java_TouchDevice_availableHoverTypes(AttachCurrentThread(),
+ GetApplicationContext());
}
HoverType GetPrimaryHoverType() {

Powered by Google App Engine
This is Rietveld 408576698