| 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);
|
| }
|
|
|