| Index: content/public/android/java/src/org/chromium/content/browser/ScreenOrientationProvider.java
|
| diff --git a/content/public/android/java/src/org/chromium/content/browser/ScreenOrientationProvider.java b/content/public/android/java/src/org/chromium/content/browser/ScreenOrientationProvider.java
|
| index 80a80cdc7f972e1b7121681b04313b1d226b3271..5fd2b41106db04aed0d7295fa03eab30ed7efaa0 100644
|
| --- a/content/public/android/java/src/org/chromium/content/browser/ScreenOrientationProvider.java
|
| +++ b/content/public/android/java/src/org/chromium/content/browser/ScreenOrientationProvider.java
|
| @@ -10,7 +10,6 @@ import android.content.pm.ActivityInfo;
|
| import android.content.pm.PackageManager;
|
| import android.view.Surface;
|
|
|
| -import org.chromium.base.ApplicationStatus;
|
| import org.chromium.base.Log;
|
| import org.chromium.base.ThreadUtils;
|
| import org.chromium.base.annotations.CalledByNative;
|
| @@ -71,14 +70,15 @@ public class ScreenOrientationProvider {
|
| }
|
| }
|
|
|
| - // Note that WindowAndroid may be null if the tab is being reparented.
|
| @CalledByNative
|
| - static void lockOrientation(@Nullable WindowAndroid window, byte orientation) {
|
| - lockOrientation(window, orientation, ApplicationStatus.getLastTrackedFocusedActivity());
|
| - }
|
| -
|
| - public static void lockOrientation(@Nullable WindowAndroid window, byte webScreenOrientation,
|
| - Activity activity) {
|
| + public static void lockOrientation(@Nullable WindowAndroid window, byte webScreenOrientation) {
|
| + // WindowAndroid may be null if the tab is being reparented.
|
| + if (window == null) return;
|
| + Activity activity = window.getActivity().get();
|
| +
|
| + // Locking orientation is only supported for web contents that have an associated activity.
|
| + // Note that we can't just use the focused activity, as that would lead to bugs where
|
| + // unlockOrientation unlocks a different activity to the one that was locked.
|
| if (activity == null) return;
|
|
|
| int orientation = getOrientationFromWebScreenOrientations(webScreenOrientation, window,
|
| @@ -90,13 +90,16 @@ public class ScreenOrientationProvider {
|
| activity.setRequestedOrientation(orientation);
|
| }
|
|
|
| - // Note that WindowAndroid may be null if the tab is being reparented.
|
| @CalledByNative
|
| static void unlockOrientation(@Nullable WindowAndroid window) {
|
| - Activity activity = ApplicationStatus.getLastTrackedFocusedActivity();
|
| - if (activity == null) {
|
| - return;
|
| - }
|
| + // WindowAndroid may be null if the tab is being reparented.
|
| + if (window == null) return;
|
| + Activity activity = window.getActivity().get();
|
| +
|
| + // Locking orientation is only supported for web contents that have an associated activity.
|
| + // Note that we can't just use the focused activity, as that would lead to bugs where
|
| + // unlockOrientation unlocks a different activity to the one that was locked.
|
| + if (activity == null) return;
|
|
|
| int defaultOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
|
|
|
|
|