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

Unified Diff: content/browser/android/content_view_core_impl.cc

Issue 1489453003: jni: Pass method parameters as JavaParamRef in content. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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: content/browser/android/content_view_core_impl.cc
diff --git a/content/browser/android/content_view_core_impl.cc b/content/browser/android/content_view_core_impl.cc
index 7aa79eefc542720c2b9e04e982dd5930607d2fee..0c3a6ae197ede5610b20b412ccdb250fc6bf87c2 100644
--- a/content/browser/android/content_view_core_impl.cc
+++ b/content/browser/android/content_view_core_impl.cc
@@ -257,19 +257,22 @@ ContentViewCoreImpl::~ContentViewCoreImpl() {
}
base::android::ScopedJavaLocalRef<jobject>
-ContentViewCoreImpl::GetWebContentsAndroid(JNIEnv* env, jobject obj) {
+ContentViewCoreImpl::GetWebContentsAndroid(JNIEnv* env,
+ const JavaParamRef<jobject>& obj) {
return web_contents_->GetJavaWebContents();
}
base::android::ScopedJavaLocalRef<jobject>
-ContentViewCoreImpl::GetJavaWindowAndroid(JNIEnv* env, jobject obj) {
+ContentViewCoreImpl::GetJavaWindowAndroid(JNIEnv* env,
+ const JavaParamRef<jobject>& obj) {
if (!window_android_)
return ScopedJavaLocalRef<jobject>();
return window_android_->GetJavaObject();
}
-void ContentViewCoreImpl::OnJavaContentViewCoreDestroyed(JNIEnv* env,
- jobject obj) {
+void ContentViewCoreImpl::OnJavaContentViewCoreDestroyed(
+ JNIEnv* env,
+ const JavaParamRef<jobject>& obj) {
DCHECK(env->IsSameObject(java_ref_.get(env).obj(), obj));
java_ref_.reset();
// Java peer has gone, ContentViewCore is not functional and waits to
@@ -811,10 +814,11 @@ const scoped_refptr<cc::Layer>& ContentViewCoreImpl::GetLayer() const {
// Methods called from Java via JNI
// ----------------------------------------------------------------------------
-void ContentViewCoreImpl::SelectPopupMenuItems(JNIEnv* env,
- jobject obj,
- jlong selectPopupSourceFrame,
- jintArray indices) {
+void ContentViewCoreImpl::SelectPopupMenuItems(
+ JNIEnv* env,
+ const JavaParamRef<jobject>& obj,
+ jlong selectPopupSourceFrame,
+ const JavaParamRef<jintArray>& indices) {
RenderFrameHostImpl* rfhi =
reinterpret_cast<RenderFrameHostImpl*>(selectPopupSourceFrame);
DCHECK(rfhi);
@@ -836,7 +840,9 @@ WebContents* ContentViewCoreImpl::GetWebContents() const {
return web_contents_;
}
-void ContentViewCoreImpl::SetFocus(JNIEnv* env, jobject obj, jboolean focused) {
+void ContentViewCoreImpl::SetFocus(JNIEnv* env,
+ const JavaParamRef<jobject>& obj,
+ jboolean focused) {
SetFocusInternal(focused);
}
@@ -850,44 +856,46 @@ void ContentViewCoreImpl::SetFocusInternal(bool focused) {
GetRenderWidgetHostViewAndroid()->Blur();
}
-void ContentViewCoreImpl::SendOrientationChangeEvent(JNIEnv* env,
- jobject obj,
- jint orientation) {
+void ContentViewCoreImpl::SendOrientationChangeEvent(
+ JNIEnv* env,
+ const JavaParamRef<jobject>& obj,
+ jint orientation) {
if (device_orientation_ != orientation) {
device_orientation_ = orientation;
SendOrientationChangeEventInternal();
}
}
-jboolean ContentViewCoreImpl::OnTouchEvent(JNIEnv* env,
- jobject obj,
- jobject motion_event,
- jlong time_ms,
- jint android_action,
- jint pointer_count,
- jint history_size,
- jint action_index,
- jfloat pos_x_0,
- jfloat pos_y_0,
- jfloat pos_x_1,
- jfloat pos_y_1,
- jint pointer_id_0,
- jint pointer_id_1,
- jfloat touch_major_0,
- jfloat touch_major_1,
- jfloat touch_minor_0,
- jfloat touch_minor_1,
- jfloat orientation_0,
- jfloat orientation_1,
- jfloat tilt_0,
- jfloat tilt_1,
- jfloat raw_pos_x,
- jfloat raw_pos_y,
- jint android_tool_type_0,
- jint android_tool_type_1,
- jint android_button_state,
- jint android_meta_state,
- jboolean is_touch_handle_event) {
+jboolean ContentViewCoreImpl::OnTouchEvent(
+ JNIEnv* env,
+ const JavaParamRef<jobject>& obj,
+ const JavaParamRef<jobject>& motion_event,
+ jlong time_ms,
+ jint android_action,
+ jint pointer_count,
+ jint history_size,
+ jint action_index,
+ jfloat pos_x_0,
+ jfloat pos_y_0,
+ jfloat pos_x_1,
+ jfloat pos_y_1,
+ jint pointer_id_0,
+ jint pointer_id_1,
+ jfloat touch_major_0,
+ jfloat touch_major_1,
+ jfloat touch_minor_0,
+ jfloat touch_minor_1,
+ jfloat orientation_0,
+ jfloat orientation_1,
+ jfloat tilt_0,
+ jfloat tilt_1,
+ jfloat raw_pos_x,
+ jfloat raw_pos_y,
+ jint android_tool_type_0,
+ jint android_tool_type_1,
+ jint android_button_state,
+ jint android_meta_state,
+ jboolean is_touch_handle_event) {
RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid();
// Avoid synthesizing a touch event if it cannot be forwarded.
if (!rwhv)
@@ -932,11 +940,12 @@ float ContentViewCoreImpl::GetDpiScale() const {
return dpi_scale_;
}
-jboolean ContentViewCoreImpl::SendMouseMoveEvent(JNIEnv* env,
- jobject obj,
- jlong time_ms,
- jfloat x,
- jfloat y) {
+jboolean ContentViewCoreImpl::SendMouseMoveEvent(
+ JNIEnv* env,
+ const JavaParamRef<jobject>& obj,
+ jlong time_ms,
+ jfloat x,
+ jfloat y) {
RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid();
if (!rwhv)
return false;
@@ -950,14 +959,15 @@ jboolean ContentViewCoreImpl::SendMouseMoveEvent(JNIEnv* env,
return true;
}
-jboolean ContentViewCoreImpl::SendMouseWheelEvent(JNIEnv* env,
- jobject obj,
- jlong time_ms,
- jfloat x,
- jfloat y,
- jfloat ticks_x,
- jfloat ticks_y,
- jfloat pixels_per_tick) {
+jboolean ContentViewCoreImpl::SendMouseWheelEvent(
+ JNIEnv* env,
+ const JavaParamRef<jobject>& obj,
+ jlong time_ms,
+ jfloat x,
+ jfloat y,
+ jfloat ticks_x,
+ jfloat ticks_y,
+ jfloat pixels_per_tick) {
RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid();
if (!rwhv)
return false;
@@ -987,7 +997,7 @@ void ContentViewCoreImpl::SendGestureEvent(
}
void ContentViewCoreImpl::ScrollBegin(JNIEnv* env,
- jobject obj,
+ const JavaParamRef<jobject>& obj,
jlong time_ms,
jfloat x,
jfloat y,
@@ -1003,14 +1013,21 @@ void ContentViewCoreImpl::ScrollBegin(JNIEnv* env,
SendGestureEvent(event);
}
-void ContentViewCoreImpl::ScrollEnd(JNIEnv* env, jobject obj, jlong time_ms) {
+void ContentViewCoreImpl::ScrollEnd(JNIEnv* env,
+ const JavaParamRef<jobject>& obj,
+ jlong time_ms) {
WebGestureEvent event = MakeGestureEvent(
WebInputEvent::GestureScrollEnd, time_ms, 0, 0);
SendGestureEvent(event);
}
-void ContentViewCoreImpl::ScrollBy(JNIEnv* env, jobject obj, jlong time_ms,
- jfloat x, jfloat y, jfloat dx, jfloat dy) {
+void ContentViewCoreImpl::ScrollBy(JNIEnv* env,
+ const JavaParamRef<jobject>& obj,
+ jlong time_ms,
+ jfloat x,
+ jfloat y,
+ jfloat dx,
+ jfloat dy) {
WebGestureEvent event = MakeGestureEvent(
WebInputEvent::GestureScrollUpdate, time_ms, x, y);
event.data.scrollUpdate.deltaX = -dx / dpi_scale();
@@ -1020,7 +1037,7 @@ void ContentViewCoreImpl::ScrollBy(JNIEnv* env, jobject obj, jlong time_ms,
}
void ContentViewCoreImpl::FlingStart(JNIEnv* env,
- jobject obj,
+ const JavaParamRef<jobject>& obj,
jlong time_ms,
jfloat x,
jfloat y,
@@ -1036,7 +1053,9 @@ void ContentViewCoreImpl::FlingStart(JNIEnv* env,
SendGestureEvent(event);
}
-void ContentViewCoreImpl::FlingCancel(JNIEnv* env, jobject obj, jlong time_ms) {
+void ContentViewCoreImpl::FlingCancel(JNIEnv* env,
+ const JavaParamRef<jobject>& obj,
+ jlong time_ms) {
WebGestureEvent event = MakeGestureEvent(
WebInputEvent::GestureFlingCancel, time_ms, 0, 0);
event.data.flingCancel.preventBoosting = true;
@@ -1044,8 +1063,11 @@ void ContentViewCoreImpl::FlingCancel(JNIEnv* env, jobject obj, jlong time_ms) {
SendGestureEvent(event);
}
-void ContentViewCoreImpl::SingleTap(JNIEnv* env, jobject obj, jlong time_ms,
- jfloat x, jfloat y) {
+void ContentViewCoreImpl::SingleTap(JNIEnv* env,
+ const JavaParamRef<jobject>& obj,
+ jlong time_ms,
+ jfloat x,
+ jfloat y) {
// Tap gestures should always be preceded by a TapDown, ensuring consistency
// with the touch-based gesture detection pipeline.
WebGestureEvent tap_down_event = MakeGestureEvent(
@@ -1059,8 +1081,11 @@ void ContentViewCoreImpl::SingleTap(JNIEnv* env, jobject obj, jlong time_ms,
SendGestureEvent(tap_event);
}
-void ContentViewCoreImpl::DoubleTap(JNIEnv* env, jobject obj, jlong time_ms,
- jfloat x, jfloat y) {
+void ContentViewCoreImpl::DoubleTap(JNIEnv* env,
+ const JavaParamRef<jobject>& obj,
+ jlong time_ms,
+ jfloat x,
+ jfloat y) {
WebGestureEvent event = MakeGestureEvent(
WebInputEvent::GestureDoubleTap, time_ms, x, y);
// Set the tap count to 1 even for DoubleTap, in order to be consistent with
@@ -1070,29 +1095,40 @@ void ContentViewCoreImpl::DoubleTap(JNIEnv* env, jobject obj, jlong time_ms,
SendGestureEvent(event);
}
-void ContentViewCoreImpl::LongPress(JNIEnv* env, jobject obj, jlong time_ms,
- jfloat x, jfloat y) {
+void ContentViewCoreImpl::LongPress(JNIEnv* env,
+ const JavaParamRef<jobject>& obj,
+ jlong time_ms,
+ jfloat x,
+ jfloat y) {
WebGestureEvent event = MakeGestureEvent(
WebInputEvent::GestureLongPress, time_ms, x, y);
SendGestureEvent(event);
}
-void ContentViewCoreImpl::PinchBegin(JNIEnv* env, jobject obj, jlong time_ms,
- jfloat x, jfloat y) {
+void ContentViewCoreImpl::PinchBegin(JNIEnv* env,
+ const JavaParamRef<jobject>& obj,
+ jlong time_ms,
+ jfloat x,
+ jfloat y) {
WebGestureEvent event = MakeGestureEvent(
WebInputEvent::GesturePinchBegin, time_ms, x, y);
SendGestureEvent(event);
}
-void ContentViewCoreImpl::PinchEnd(JNIEnv* env, jobject obj, jlong time_ms) {
+void ContentViewCoreImpl::PinchEnd(JNIEnv* env,
+ const JavaParamRef<jobject>& obj,
+ jlong time_ms) {
WebGestureEvent event = MakeGestureEvent(
WebInputEvent::GesturePinchEnd, time_ms, 0, 0);
SendGestureEvent(event);
}
-void ContentViewCoreImpl::PinchBy(JNIEnv* env, jobject obj, jlong time_ms,
- jfloat anchor_x, jfloat anchor_y,
+void ContentViewCoreImpl::PinchBy(JNIEnv* env,
+ const JavaParamRef<jobject>& obj,
+ jlong time_ms,
+ jfloat anchor_x,
+ jfloat anchor_y,
jfloat delta) {
WebGestureEvent event = MakeGestureEvent(
WebInputEvent::GesturePinchUpdate, time_ms, anchor_x, anchor_y);
@@ -1101,51 +1137,63 @@ void ContentViewCoreImpl::PinchBy(JNIEnv* env, jobject obj, jlong time_ms,
SendGestureEvent(event);
}
-void ContentViewCoreImpl::SelectBetweenCoordinates(JNIEnv* env, jobject obj,
- jfloat x1, jfloat y1,
- jfloat x2, jfloat y2) {
+void ContentViewCoreImpl::SelectBetweenCoordinates(
+ JNIEnv* env,
+ const JavaParamRef<jobject>& obj,
+ jfloat x1,
+ jfloat y1,
+ jfloat x2,
+ jfloat y2) {
SelectBetweenCoordinates(gfx::PointF(x1 / dpi_scale(), y1 / dpi_scale()),
gfx::PointF(x2 / dpi_scale(), y2 / dpi_scale()));
}
-void ContentViewCoreImpl::MoveCaret(JNIEnv* env, jobject obj,
- jfloat x, jfloat y) {
+void ContentViewCoreImpl::MoveCaret(JNIEnv* env,
+ const JavaParamRef<jobject>& obj,
+ jfloat x,
+ jfloat y) {
RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid();
if (rwhv)
rwhv->MoveCaret(gfx::Point(x / dpi_scale_, y / dpi_scale_));
}
-void ContentViewCoreImpl::DismissTextHandles(JNIEnv* env, jobject obj) {
+void ContentViewCoreImpl::DismissTextHandles(JNIEnv* env,
+ const JavaParamRef<jobject>& obj) {
RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid();
if (rwhv)
rwhv->DismissTextHandles();
}
-void ContentViewCoreImpl::SetTextHandlesTemporarilyHidden(JNIEnv* env,
- jobject obj,
- jboolean hidden) {
+void ContentViewCoreImpl::SetTextHandlesTemporarilyHidden(
+ JNIEnv* env,
+ const JavaParamRef<jobject>& obj,
+ jboolean hidden) {
RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid();
if (rwhv)
rwhv->SetTextHandlesTemporarilyHidden(hidden);
}
-void ContentViewCoreImpl::ResetGestureDetection(JNIEnv* env, jobject obj) {
+void ContentViewCoreImpl::ResetGestureDetection(
+ JNIEnv* env,
+ const JavaParamRef<jobject>& obj) {
RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid();
if (rwhv)
rwhv->ResetGestureDetection();
}
-void ContentViewCoreImpl::SetDoubleTapSupportEnabled(JNIEnv* env,
- jobject obj,
- jboolean enabled) {
+void ContentViewCoreImpl::SetDoubleTapSupportEnabled(
+ JNIEnv* env,
+ const JavaParamRef<jobject>& obj,
+ jboolean enabled) {
RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid();
if (rwhv)
rwhv->SetDoubleTapSupportEnabled(enabled);
}
-void ContentViewCoreImpl::SetMultiTouchZoomSupportEnabled(JNIEnv* env,
- jobject obj,
- jboolean enabled) {
+void ContentViewCoreImpl::SetMultiTouchZoomSupportEnabled(
+ JNIEnv* env,
+ const JavaParamRef<jobject>& obj,
+ jboolean enabled) {
RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid();
if (rwhv)
rwhv->SetMultiTouchZoomSupportEnabled(enabled);
@@ -1153,31 +1201,31 @@ void ContentViewCoreImpl::SetMultiTouchZoomSupportEnabled(JNIEnv* env,
void ContentViewCoreImpl::SetAllowJavascriptInterfacesInspection(
JNIEnv* env,
- jobject obj,
+ const JavaParamRef<jobject>& obj,
jboolean allow) {
java_bridge_dispatcher_host_->SetAllowObjectContentsInspection(allow);
}
void ContentViewCoreImpl::AddJavascriptInterface(
JNIEnv* env,
- jobject /* obj */,
- jobject object,
- jstring name,
- jclass safe_annotation_clazz) {
- ScopedJavaLocalRef<jobject> scoped_object(env, object);
- ScopedJavaLocalRef<jclass> scoped_clazz(env, safe_annotation_clazz);
+ const JavaParamRef<jobject>& /* obj */,
+ const JavaParamRef<jobject>& object,
+ const JavaParamRef<jstring>& name,
+ const JavaParamRef<jclass>& safe_annotation_clazz) {
java_bridge_dispatcher_host_->AddNamedObject(
- ConvertJavaStringToUTF8(env, name), scoped_object, scoped_clazz);
+ ConvertJavaStringToUTF8(env, name), object, safe_annotation_clazz);
Torne 2015/11/30 11:47:06 manual change: no need to construct ScopedJavaLoca
}
-void ContentViewCoreImpl::RemoveJavascriptInterface(JNIEnv* env,
- jobject /* obj */,
- jstring name) {
+void ContentViewCoreImpl::RemoveJavascriptInterface(
+ JNIEnv* env,
+ const JavaParamRef<jobject>& /* obj */,
+ const JavaParamRef<jstring>& name) {
java_bridge_dispatcher_host_->RemoveNamedObject(
ConvertJavaStringToUTF8(env, name));
}
-void ContentViewCoreImpl::WasResized(JNIEnv* env, jobject obj) {
+void ContentViewCoreImpl::WasResized(JNIEnv* env,
+ const JavaParamRef<jobject>& obj) {
RenderWidgetHostViewAndroid* view = GetRenderWidgetHostViewAndroid();
gfx::Size physical_size(
Java_ContentViewCore_getPhysicalBackingWidthPix(env, obj),
@@ -1192,7 +1240,9 @@ void ContentViewCoreImpl::WasResized(JNIEnv* env, jobject obj) {
}
}
-long ContentViewCoreImpl::GetNativeImeAdapter(JNIEnv* env, jobject obj) {
+long ContentViewCoreImpl::GetNativeImeAdapter(
+ JNIEnv* env,
+ const JavaParamRef<jobject>& obj) {
RenderWidgetHostViewAndroid* rwhva = GetRenderWidgetHostViewAndroid();
if (!rwhva)
return 0;
@@ -1238,21 +1288,24 @@ void ContentViewCoreImpl::UpdateImeAdapter(long native_ime_adapter,
is_non_ime_change);
}
-void ContentViewCoreImpl::SetAccessibilityEnabled(JNIEnv* env, jobject obj,
- bool enabled) {
+void ContentViewCoreImpl::SetAccessibilityEnabled(
+ JNIEnv* env,
+ const JavaParamRef<jobject>& obj,
+ bool enabled) {
SetAccessibilityEnabledInternal(enabled);
}
-void ContentViewCoreImpl::SetTextTrackSettings(JNIEnv* env,
- jobject obj,
- jboolean textTracksEnabled,
- jstring textTrackBackgroundColor,
- jstring textTrackFontFamily,
- jstring textTrackFontStyle,
- jstring textTrackFontVariant,
- jstring textTrackTextColor,
- jstring textTrackTextShadow,
- jstring textTrackTextSize) {
+void ContentViewCoreImpl::SetTextTrackSettings(
+ JNIEnv* env,
+ const JavaParamRef<jobject>& obj,
+ jboolean textTracksEnabled,
+ const JavaParamRef<jstring>& textTrackBackgroundColor,
+ const JavaParamRef<jstring>& textTrackFontFamily,
+ const JavaParamRef<jstring>& textTrackFontStyle,
+ const JavaParamRef<jstring>& textTrackFontVariant,
+ const JavaParamRef<jstring>& textTrackTextColor,
+ const JavaParamRef<jstring>& textTrackTextShadow,
+ const JavaParamRef<jstring>& textTrackTextSize) {
FrameMsg_TextTrackSettings_Params params;
params.text_tracks_enabled = textTracksEnabled;
params.text_track_background_color = ConvertJavaStringToUTF8(
@@ -1311,7 +1364,7 @@ void ContentViewCoreImpl::SendOrientationChangeEventInternal() {
}
void ContentViewCoreImpl::ExtractSmartClipData(JNIEnv* env,
- jobject obj,
+ const JavaParamRef<jobject>& obj,
jint x,
jint y,
jint width,
@@ -1327,13 +1380,16 @@ void ContentViewCoreImpl::ExtractSmartClipData(JNIEnv* env,
GetWebContents()->GetRoutingID(), rect));
}
-jint ContentViewCoreImpl::GetCurrentRenderProcessId(JNIEnv* env, jobject obj) {
+jint ContentViewCoreImpl::GetCurrentRenderProcessId(
+ JNIEnv* env,
+ const JavaParamRef<jobject>& obj) {
return GetRenderProcessIdFromRenderViewHost(
web_contents_->GetRenderViewHost());
}
-void ContentViewCoreImpl::SetBackgroundOpaque(JNIEnv* env, jobject jobj,
- jboolean opaque) {
+void ContentViewCoreImpl::SetBackgroundOpaque(JNIEnv* env,
+ const JavaParamRef<jobject>& jobj,
+ jboolean opaque) {
if (GetRenderWidgetHostViewAndroid()) {
if (opaque)
GetRenderWidgetHostViewAndroid()->SetBackgroundColorToDefault();

Powered by Google App Engine
This is Rietveld 408576698