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

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

Issue 2319863005: Implement new compositor and ContentViewCore reparenting for VR Shell. (Closed)
Patch Set: Address comments Created 4 years, 3 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: chrome/android/java/src/org/chromium/chrome/browser/vr_shell/VrShellDelegate.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/vr_shell/VrShellDelegate.java b/chrome/android/java/src/org/chromium/chrome/browser/vr_shell/VrShellDelegate.java
index 46a55a1fa806a86f66f032cb89be127d95396dac..9e66af9d65ddc0880776caa0f6a3c9f81b0dd481 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/vr_shell/VrShellDelegate.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/vr_shell/VrShellDelegate.java
@@ -15,6 +15,7 @@ import android.view.WindowManager;
import org.chromium.base.Log;
import org.chromium.chrome.browser.ChromeTabbedActivity;
+import org.chromium.chrome.browser.tab.Tab;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
@@ -71,6 +72,12 @@ public class VrShellDelegate {
*/
public boolean enterVRIfNecessary() {
if (!mVrShellEnabled) return false;
+ Tab tab = mActivity.getActivityTab();
+ // TODO(mthiesse): When we have VR UI for opening new tabs, etc., allow VR Shell to be
+ // entered without any current tabs.
+ if (tab == null || tab.getContentViewCore() == null) {
+ return false;
+ }
if (mInVr) return true;
// VrShell must be initialized in Landscape mode due to a bug in the GVR library.
mActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
@@ -80,7 +87,7 @@ public class VrShellDelegate {
}
addVrViews();
setupVrModeWindowFlags();
- mVrShellView.onNativeLibraryReady();
+ mVrShellView.onNativeLibraryReady(tab);
mVrShellView.setVrModeEnabled(true);
mInVr = true;
return true;
@@ -120,8 +127,10 @@ public class VrShellDelegate {
private boolean createVrShell() {
StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
try {
- Constructor<?> vrShellConstructor = mVrShellClass.getConstructor(Activity.class);
- mVrShellView = (VrShellInterface) vrShellConstructor.newInstance(mActivity);
+ Constructor<?> vrShellConstructor = mVrShellClass.getConstructor(Activity.class,
+ ViewGroup.class);
+ mVrShellView = (VrShellInterface) vrShellConstructor.newInstance(mActivity,
+ mParentView);
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException
| InvocationTargetException | NoSuchMethodException e) {
Log.e(TAG, "Unable to instantiate VrShell", e);
@@ -136,9 +145,11 @@ public class VrShellDelegate {
LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT,
LayoutParams.MATCH_PARENT);
mParentView.addView(mVrShellView.getContainer(), mParentView.getChildCount(), params);
+ mActivity.setUIVisibilityForVR(View.GONE);
amp 2016/09/12 22:36:53 I read this now as saying it's setting the VR visi
mthiesse 2016/09/13 19:04:04 I think setUIVisibilityForVR makes sense in the co
}
private void removeVrViews() {
+ mActivity.setUIVisibilityForVR(View.VISIBLE);
((ViewGroup) mVrShellView.getContainer().getParent())
.removeView(mVrShellView.getContainer());
}

Powered by Google App Engine
This is Rietveld 408576698