Chromium Code Reviews| 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 4debec59ab4641db031e49bea713768e971c1777..b4988bcde1cd8815d1bff260ece6e02389ec0450 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 |
| @@ -48,6 +48,7 @@ import org.chromium.chrome.browser.customtabs.CustomTabActivity; |
| import org.chromium.chrome.browser.help.HelpAndFeedback; |
| import org.chromium.chrome.browser.infobar.InfoBarIdentifier; |
| import org.chromium.chrome.browser.infobar.SimpleConfirmInfoBarBuilder; |
| +import org.chromium.chrome.browser.page_info.PageInfoPopup; |
| import org.chromium.chrome.browser.tab.Tab; |
| import org.chromium.chrome.browser.tabmodel.TabModelSelector; |
| import org.chromium.chrome.browser.util.IntentUtils; |
| @@ -135,6 +136,9 @@ public class VrShellDelegate implements ApplicationStatus.ActivityStateListener, |
| // Best effort whether or not the system was in VR when Chrome launched. |
| private Boolean mInVrAtChromeLaunch; |
| private boolean mShowingDaydreamDoff; |
| + // Whether we should show the PageInfo UI. This is shown when we force exit the user |
| + // out of VR when they attempt to view the PageInfo from VR. |
|
cjgrant
2017/06/02 04:16:35
s/from VR// maybe, as it's already stated that you
ymalik
2017/06/02 21:14:31
Done.
|
| + private boolean mShouldShowPageInfo; |
| private boolean mExitingCct; |
| private boolean mPaused; |
| private int mRestoreSystemUiVisibilityFlag = -1; |
| @@ -460,6 +464,7 @@ public class VrShellDelegate implements ApplicationStatus.ActivityStateListener, |
| assert !mInVr || mShowingDaydreamDoff; |
| if (mInVr && activity != mActivity) { |
| if (mShowingDaydreamDoff) { |
| + mShouldShowPageInfo = false; |
| onExitVrResult(true); |
| } else { |
| // We should never reach this state currently, but just in case... |
| @@ -577,6 +582,7 @@ public class VrShellDelegate implements ApplicationStatus.ActivityStateListener, |
| } |
| mVrClassesWrapper.setVrModeEnabled(mActivity, true); |
| mInVr = true; |
| + mShouldShowPageInfo = false; |
| // Lock orientation to landscape after enter VR. |
| mActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); |
| @@ -843,6 +849,10 @@ public class VrShellDelegate implements ApplicationStatus.ActivityStateListener, |
| mShowingDaydreamDoff = false; |
| + if (mShouldShowPageInfo) { |
| + sInstance.showPageInfoPopup(); |
| + } |
| + |
| shutdownVr(true /* disableVrMode */, false /* canReenter */, |
| !mExitingCct /* stayingInChrome */); |
| if (mExitingCct) ((CustomTabActivity) mActivity).finishAndClose(false); |
| @@ -920,6 +930,7 @@ public class VrShellDelegate implements ApplicationStatus.ActivityStateListener, |
| if (disableVrMode) mVrClassesWrapper.setVrModeEnabled(mActivity, false); |
| promptForFeedbackIfNeeded(stayingInChrome); |
| + mShouldShowPageInfo = false; |
| } |
| /* package */ void showDoffAndExitVr() { |
| @@ -931,6 +942,11 @@ public class VrShellDelegate implements ApplicationStatus.ActivityStateListener, |
| shutdownVr(true /* disableVrMode */, false /* canReenter */, true /* stayingInChrome */); |
| } |
| + /* package */ void onUnhandledPageInfo() { |
| + mShouldShowPageInfo = true; |
| + showDoffAndExitVr(); |
| + } |
| + |
| /* package */ void exitCct() { |
| if (mShowingDaydreamDoff) return; |
| assert mActivity instanceof CustomTabActivity; |
| @@ -943,6 +959,15 @@ public class VrShellDelegate implements ApplicationStatus.ActivityStateListener, |
| } |
| } |
| + private void showPageInfoPopup() { |
| + assert mShouldShowPageInfo; |
| + // Note: we don't set mShouldShowPageInfo to false here because we don't |
| + // want to show the feedback prompt when the user exits VR to view PageInfo. So this gets |
| + // reset in shutdownVr. |
| + PageInfoPopup.show( |
| + mActivity, mActivity.getActivityTab(), null, PageInfoPopup.OPENED_FROM_VR); |
| + } |
| + |
| private static void startFeedback(Tab tab) { |
| // TODO(ymalik): This call will connect to the Google Services api which can be slow. Can we |
| // connect to it beforehand when we know that we'll be prompting for feedback? |
| @@ -984,12 +1009,14 @@ public class VrShellDelegate implements ApplicationStatus.ActivityStateListener, |
| // 1) The user hasn't explicitly opted-out of it in the past |
| // 2) The user has performed VR browsing |
| // 3) The user is exiting VR and going back into 2D Chrome |
| - // 4) Every n'th visit (where n = mFeedbackFrequency) |
| + // 4) We're not exiting to complete an unsupported VR action in 2D (e.g. viewing PageInfo) |
| + // 5) Every n'th visit (where n = mFeedbackFrequency) |
| if (!activitySupportsExitFeedback(mActivity)) return; |
| if (!stayingInChrome) return; |
| if (VrFeedbackStatus.getFeedbackOptOut()) return; |
| if (!mVrBrowserUsed) return; |
| + if (mShouldShowPageInfo) return; |
| int exitCount = VrFeedbackStatus.getUserExitedAndEntered2DCount(); |
| VrFeedbackStatus.setUserExitedAndEntered2DCount((exitCount + 1) % mFeedbackFrequency); |