| OLD | NEW |
| 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.PendingIntent; | 8 import android.app.PendingIntent; |
| 9 import android.content.ComponentName; | 9 import android.content.ComponentName; |
| 10 import android.content.Intent; | 10 import android.content.Intent; |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 // non-VR recents, and we don't want ChromeTabbedActivity disappearing,
exit VR. | 293 // non-VR recents, and we don't want ChromeTabbedActivity disappearing,
exit VR. |
| 294 exitVRIfNecessary(false); | 294 exitVRIfNecessary(false); |
| 295 } | 295 } |
| 296 | 296 |
| 297 /** | 297 /** |
| 298 * Exits the current VR mode (WebVR or VRShell) | 298 * Exits the current VR mode (WebVR or VRShell) |
| 299 * @return Whether or not we exited VR. | 299 * @return Whether or not we exited VR. |
| 300 */ | 300 */ |
| 301 public boolean exitVRIfNecessary(boolean returnTo2D) { | 301 public boolean exitVRIfNecessary(boolean returnTo2D) { |
| 302 if (!mInVr) return false; | 302 if (!mInVr) return false; |
| 303 // If WebVR is presenting instruct it to exit. | |
| 304 nativeExitWebVRIfNecessary(mNativeVrShellDelegate); | |
| 305 shutdownVR(returnTo2D); | 303 shutdownVR(returnTo2D); |
| 306 return true; | 304 return true; |
| 307 } | 305 } |
| 308 | 306 |
| 309 public void onExitVRResult(int resultCode) { | 307 public void onExitVRResult(int resultCode) { |
| 310 if (resultCode == Activity.RESULT_OK) { | 308 if (resultCode == Activity.RESULT_OK) { |
| 311 mVrDaydreamApi.setVrModeEnabled(false); | 309 mVrDaydreamApi.setVrModeEnabled(false); |
| 312 } else { | 310 } else { |
| 313 // For now, we don't handle re-entering VR when exit fails, so keep
trying to exit. | 311 // For now, we don't handle re-entering VR when exit fails, so keep
trying to exit. |
| 314 mVrDaydreamApi.exitFromVr(EXIT_VR_RESULT, new Intent()); | 312 mVrDaydreamApi.exitFromVr(EXIT_VR_RESULT, new Intent()); |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 531 | 529 |
| 532 /** | 530 /** |
| 533 * @return Pointer to the native VrShellDelegate object. | 531 * @return Pointer to the native VrShellDelegate object. |
| 534 */ | 532 */ |
| 535 @CalledByNative | 533 @CalledByNative |
| 536 private long getNativePointer() { | 534 private long getNativePointer() { |
| 537 return mNativeVrShellDelegate; | 535 return mNativeVrShellDelegate; |
| 538 } | 536 } |
| 539 | 537 |
| 540 private native long nativeInit(); | 538 private native long nativeInit(); |
| 541 private native void nativeExitWebVRIfNecessary(long nativeVrShellDelegate); | |
| 542 } | 539 } |
| OLD | NEW |