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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/vr_shell/VrShellImpl.java

Issue 2773903003: Add way to get native VR UI information from Java (Closed)
Patch Set: Remove comment Created 3 years, 9 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
« no previous file with comments | « no previous file | chrome/android/java_sources.gni » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/vr_shell/VrShellImpl.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/vr_shell/VrShellImpl.java b/chrome/android/java/src/org/chromium/chrome/browser/vr_shell/VrShellImpl.java
index 777990dbddc45e396757af2cf842843b94fa8125..4274eee3cb6458f97ac622aebc69ca00c4c1bf3b 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/vr_shell/VrShellImpl.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/vr_shell/VrShellImpl.java
@@ -20,6 +20,9 @@ import android.widget.FrameLayout.LayoutParams;
import com.google.vr.ndk.base.AndroidCompat;
import com.google.vr.ndk.base.GvrLayout;
+import org.json.JSONException;
+import org.json.JSONObject;
+
import org.chromium.base.CommandLine;
import org.chromium.base.Log;
import org.chromium.base.ThreadUtils;
@@ -57,6 +60,9 @@ import org.chromium.ui.base.WindowAndroid;
import org.chromium.ui.display.DisplayAndroid;
import org.chromium.ui.display.VirtualDisplayAndroid;
+import java.util.HashMap;
+import java.util.Iterator;
+
/**
* This view extends from GvrLayout which wraps a GLSurfaceView that renders VR shell.
*/
@@ -98,6 +104,8 @@ public class VrShellImpl
private Surface mSurface;
private View mPresentationView;
+ private OnUiElementInfoReplyCallback mUiElementInfoReplyCallback;
+
// The tab that holds the main ContentViewCore.
private Tab mTab;
private NativePage mNativePage;
@@ -648,6 +656,36 @@ public class VrShellImpl
mOnDispatchTouchEventForTesting = callback;
}
+ @VisibleForTesting
+ public WebContents getUiContentsForTesting() {
+ return mUiContents;
+ }
+
+ /**
+ * Sends an asynchronous request for native UI element information.
+ * @param elementNames The names of all the elements you want info on
+ * @param onReply The runnable that will be run when native replies
+ */
+ @VisibleForTesting
+ public void requestUiElementInfoFromNativeForTesting(
+ String[] elementNames, OnUiElementInfoReplyCallback onReply) {
+ mUiElementInfoReplyCallback = onReply;
+ nativeRequestUiElementInfoForTesting(mNativeVrShell, elementNames);
+ }
+
+ @CalledByNative
+ public void replyToUiElementInfoRequestForTesting(String jsonString) throws JSONException {
+ JSONObject reply = new JSONObject(jsonString);
+ HashMap<String, JSONObject> uiElementInfo = new HashMap<String, JSONObject>();
+ for (Iterator<String> iter = reply.keys(); iter.hasNext();) {
+ String key = iter.next();
+ uiElementInfo.put(key, reply.optJSONObject(key));
+ }
+ if (mUiElementInfoReplyCallback != null) {
+ mUiElementInfoReplyCallback.onUiElementInfoReply(uiElementInfo);
+ }
+ }
+
private native long nativeInit(WebContents uiWebContents, long nativeContentWindowAndroid,
long nativeUiWindowAndroid, boolean forWebVR, VrShellDelegate delegate, long gvrApi,
boolean reprojectedRendering);
@@ -674,4 +712,6 @@ public class VrShellImpl
private native void nativeRestoreContentSurface(long nativeVrShell);
private native void nativeSetHistoryButtonsEnabled(
long nativeVrShell, boolean canGoBack, boolean canGoForward);
+ private native void nativeRequestUiElementInfoForTesting(
+ long nativeVrShell, String[] elementNames);
}
« no previous file with comments | « no previous file | chrome/android/java_sources.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698