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

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

Issue 2829193003: Autopresent WebVR content in CCT if it was opened by a Daydream Intent (Closed)
Patch Set: reviews Created 3 years, 8 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 unified diff | Download patch
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabActivity.java ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chrome.browser.vr_shell; 5 package org.chromium.chrome.browser.vr_shell;
6 6
7 import android.app.Activity; 7 import android.app.Activity;
8 import android.app.ActivityManager; 8 import android.app.ActivityManager;
9 import android.app.PendingIntent; 9 import android.app.PendingIntent;
10 import android.content.BroadcastReceiver; 10 import android.content.BroadcastReceiver;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 private @interface EnterVRResult {} 71 private @interface EnterVRResult {}
72 72
73 private static final int VR_NOT_AVAILABLE = 0; 73 private static final int VR_NOT_AVAILABLE = 0;
74 private static final int VR_CARDBOARD = 1; 74 private static final int VR_CARDBOARD = 1;
75 private static final int VR_DAYDREAM = 2; // Supports both Cardboard and Day dream viewer. 75 private static final int VR_DAYDREAM = 2; // Supports both Cardboard and Day dream viewer.
76 76
77 @Retention(RetentionPolicy.SOURCE) 77 @Retention(RetentionPolicy.SOURCE)
78 @IntDef({VR_NOT_AVAILABLE, VR_CARDBOARD, VR_DAYDREAM}) 78 @IntDef({VR_NOT_AVAILABLE, VR_CARDBOARD, VR_DAYDREAM})
79 private @interface VrSupportLevel {} 79 private @interface VrSupportLevel {}
80 80
81 private static final String DAYDREAM_VR_EXTRA = "android.intent.extra.VR_LAU NCH";
82
81 // Linter and formatter disagree on how the line below should be formatted. 83 // Linter and formatter disagree on how the line below should be formatted.
82 /* package */ 84 /* package */
83 static final String VR_ENTRY_RESULT_ACTION = 85 static final String VR_ENTRY_RESULT_ACTION =
84 "org.chromium.chrome.browser.vr_shell.VrEntryResult"; 86 "org.chromium.chrome.browser.vr_shell.VrEntryResult";
85 87
86 private static final long REENTER_VR_TIMEOUT_MS = 1000; 88 private static final long REENTER_VR_TIMEOUT_MS = 1000;
87 89
88 private static final int VR_SYSTEM_UI_FLAGS = View.SYSTEM_UI_FLAG_LAYOUT_STA BLE 90 private static final int VR_SYSTEM_UI_FLAGS = View.SYSTEM_UI_FLAG_LAYOUT_STA BLE
89 | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_L AYOUT_FULLSCREEN 91 | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_L AYOUT_FULLSCREEN
90 | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCRE EN 92 | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCRE EN
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 public static void maybeUnregisterVrEntryHook(ChromeActivity activity) { 252 public static void maybeUnregisterVrEntryHook(ChromeActivity activity) {
251 if (sInstance != null) return; // Will be handled in onPause. 253 if (sInstance != null) return; // Will be handled in onPause.
252 if (!activitySupportsVrBrowsing(activity)) return; 254 if (!activitySupportsVrBrowsing(activity)) return;
253 VrClassesWrapper wrapper = getVrClassesWrapper(); 255 VrClassesWrapper wrapper = getVrClassesWrapper();
254 if (wrapper == null) return; 256 if (wrapper == null) return;
255 VrDaydreamApi api = wrapper.createVrDaydreamApi(activity); 257 VrDaydreamApi api = wrapper.createVrDaydreamApi(activity);
256 if (api == null) return; 258 if (api == null) return;
257 unregisterDaydreamIntent(api); 259 unregisterDaydreamIntent(api);
258 } 260 }
259 261
262 /**
263 * Whether or not the intent is a Daydream VR Intent.
264 */
265 public static boolean isDaydreamVrIntent(Intent intent) {
266 return intent.getBooleanExtra(DAYDREAM_VR_EXTRA, false);
267 }
268
260 @CalledByNative 269 @CalledByNative
261 private static VrShellDelegate getInstance() { 270 private static VrShellDelegate getInstance() {
262 Activity activity = ApplicationStatus.getLastTrackedFocusedActivity(); 271 Activity activity = ApplicationStatus.getLastTrackedFocusedActivity();
263 if (!(activity instanceof ChromeActivity)) return null; 272 if (!(activity instanceof ChromeActivity)) return null;
264 return getInstance((ChromeActivity) activity); 273 return getInstance((ChromeActivity) activity);
265 } 274 }
266 275
267 private static VrShellDelegate getInstance(ChromeActivity activity) { 276 private static VrShellDelegate getInstance(ChromeActivity activity) {
268 if (!LibraryLoader.isInitialized()) return null; 277 if (!LibraryLoader.isInitialized()) return null;
269 if (activity == null || !activitySupportsPresentation(activity)) return null; 278 if (activity == null || !activitySupportsPresentation(activity)) return null;
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 } 691 }
683 692
684 @CalledByNative 693 @CalledByNative
685 private void setListeningForWebVrActivate(boolean listening) { 694 private void setListeningForWebVrActivate(boolean listening) {
686 // Non-Daydream devices may not have the concept of display activate. So disable 695 // Non-Daydream devices may not have the concept of display activate. So disable
687 // mListeningForWebVrActivate for them. 696 // mListeningForWebVrActivate for them.
688 if (mVrSupportLevel != VR_DAYDREAM) return; 697 if (mVrSupportLevel != VR_DAYDREAM) return;
689 mListeningForWebVrActivate = listening; 698 mListeningForWebVrActivate = listening;
690 if (listening) { 699 if (listening) {
691 registerDaydreamIntent(mVrDaydreamApi, mActivity); 700 registerDaydreamIntent(mVrDaydreamApi, mActivity);
701 if (mActivity.shouldAutoPresent()) {
702 // Dispatch a vrdisplayactivate event to trigger WebVR page call ing requestPresent.
703 // This should start WebVR presentation.
704 nativeDisplayActivate(mNativeVrShellDelegate);
705 }
692 } else { 706 } else {
693 unregisterDaydreamIntent(mVrDaydreamApi); 707 unregisterDaydreamIntent(mVrDaydreamApi);
694 } 708 }
695 } 709 }
696 710
697 /** 711 /**
698 * Exits VR Shell, performing all necessary cleanup. 712 * Exits VR Shell, performing all necessary cleanup.
699 */ 713 */
700 /* package */ void shutdownVr(boolean isPausing, boolean showTransition) { 714 /* package */ void shutdownVr(boolean isPausing, boolean showTransition) {
701 if (!mInVr) return; 715 if (!mInVr) return;
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
871 private native long nativeInit(); 885 private native long nativeInit();
872 private static native void nativeOnLibraryAvailable(); 886 private static native void nativeOnLibraryAvailable();
873 private native void nativeSetPresentResult(long nativeVrShellDelegate, boole an result); 887 private native void nativeSetPresentResult(long nativeVrShellDelegate, boole an result);
874 private native void nativeDisplayActivate(long nativeVrShellDelegate); 888 private native void nativeDisplayActivate(long nativeVrShellDelegate);
875 private native void nativeUpdateVSyncInterval(long nativeVrShellDelegate, lo ng timebaseNanos, 889 private native void nativeUpdateVSyncInterval(long nativeVrShellDelegate, lo ng timebaseNanos,
876 double intervalSeconds); 890 double intervalSeconds);
877 private native void nativeOnPause(long nativeVrShellDelegate); 891 private native void nativeOnPause(long nativeVrShellDelegate);
878 private native void nativeOnResume(long nativeVrShellDelegate); 892 private native void nativeOnResume(long nativeVrShellDelegate);
879 private native void nativeDestroy(long nativeVrShellDelegate); 893 private native void nativeDestroy(long nativeVrShellDelegate);
880 } 894 }
OLDNEW
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabActivity.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698