| Index: ui/android/java/src/org/chromium/ui/base/ActivityWindowAndroid.java
|
| diff --git a/ui/android/java/src/org/chromium/ui/base/ActivityWindowAndroid.java b/ui/android/java/src/org/chromium/ui/base/ActivityWindowAndroid.java
|
| index ad02b45884a08c9467fb8c7ead4a291f31a0a9e4..615b0ab7eee34dd224477a541a376f51ff3d8632 100644
|
| --- a/ui/android/java/src/org/chromium/ui/base/ActivityWindowAndroid.java
|
| +++ b/ui/android/java/src/org/chromium/ui/base/ActivityWindowAndroid.java
|
| @@ -41,7 +41,6 @@ public class ActivityWindowAndroid
|
|
|
| private static final String PERMISSION_QUERIED_KEY_PREFIX = "HasRequestedAndroidPermission::";
|
|
|
| - private final WeakReference<Activity> mActivityRef;
|
| private final Handler mHandler;
|
| private final SparseArray<PermissionCallback> mOutstandingPermissionRequests;
|
|
|
| @@ -63,8 +62,7 @@ public class ActivityWindowAndroid
|
| * @param listenToActivityState Whether to listen to activity state changes.
|
| */
|
| public ActivityWindowAndroid(Activity activity, boolean listenToActivityState) {
|
| - super(activity.getApplicationContext());
|
| - mActivityRef = new WeakReference<Activity>(activity);
|
| + super(activity);
|
| mHandler = new Handler();
|
| mOutstandingPermissionRequests = new SparseArray<PermissionCallback>();
|
| if (listenToActivityState) {
|
| @@ -76,16 +74,16 @@ public class ActivityWindowAndroid
|
|
|
| @Override
|
| protected void registerKeyboardVisibilityCallbacks() {
|
| - Activity activity = mActivityRef.get();
|
| + Activity activity = getActivity().get();
|
| if (activity == null) return;
|
| View content = activity.findViewById(android.R.id.content);
|
| - mIsKeyboardShowing = UiUtils.isKeyboardShowing(mActivityRef.get(), content);
|
| + mIsKeyboardShowing = UiUtils.isKeyboardShowing(getActivity().get(), content);
|
| content.addOnLayoutChangeListener(this);
|
| }
|
|
|
| @Override
|
| protected void unregisterKeyboardVisibilityCallbacks() {
|
| - Activity activity = mActivityRef.get();
|
| + Activity activity = getActivity().get();
|
| if (activity == null) return;
|
| activity.findViewById(android.R.id.content).removeOnLayoutChangeListener(this);
|
| }
|
| @@ -93,7 +91,7 @@ public class ActivityWindowAndroid
|
| @Override
|
| public int showCancelableIntent(
|
| PendingIntent intent, IntentCallback callback, Integer errorId) {
|
| - Activity activity = mActivityRef.get();
|
| + Activity activity = getActivity().get();
|
| if (activity == null) return START_INTENT_FAILURE;
|
|
|
| int requestCode = generateNextRequestCode();
|
| @@ -111,7 +109,7 @@ public class ActivityWindowAndroid
|
|
|
| @Override
|
| public int showCancelableIntent(Intent intent, IntentCallback callback, Integer errorId) {
|
| - Activity activity = mActivityRef.get();
|
| + Activity activity = getActivity().get();
|
| if (activity == null) return START_INTENT_FAILURE;
|
|
|
| int requestCode = generateNextRequestCode();
|
| @@ -128,7 +126,7 @@ public class ActivityWindowAndroid
|
|
|
| @Override
|
| public void cancelIntent(int requestCode) {
|
| - Activity activity = mActivityRef.get();
|
| + Activity activity = getActivity().get();
|
| if (activity == null) return;
|
| activity.finishActivity(requestCode);
|
| }
|
| @@ -190,7 +188,7 @@ public class ActivityWindowAndroid
|
| */
|
| public boolean onRequestPermissionsResult(int requestCode, String[] permissions,
|
| int[] grantResults) {
|
| - Activity activity = mActivityRef.get();
|
| + Activity activity = getActivity().get();
|
| assert activity != null;
|
|
|
| SharedPreferences.Editor editor =
|
| @@ -209,8 +207,7 @@ public class ActivityWindowAndroid
|
|
|
| @Override
|
| public WeakReference<Activity> getActivity() {
|
| - // Return a new WeakReference to prevent clients from releasing our internal WeakReference.
|
| - return new WeakReference<Activity>(mActivityRef.get());
|
| + return new WeakReference<Activity>((Activity) getContext().get());
|
| }
|
|
|
| @Override
|
| @@ -225,7 +222,7 @@ public class ActivityWindowAndroid
|
| @Override
|
| public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft,
|
| int oldTop, int oldRight, int oldBottom) {
|
| - keyboardVisibilityPossiblyChanged(UiUtils.isKeyboardShowing(mActivityRef.get(), v));
|
| + keyboardVisibilityPossiblyChanged(UiUtils.isKeyboardShowing(getActivity().get(), v));
|
| }
|
|
|
| private int generateNextRequestCode() {
|
| @@ -251,7 +248,7 @@ public class ActivityWindowAndroid
|
| public boolean canRequestPermission(String permission) {
|
| if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) return false;
|
|
|
| - Activity activity = mActivityRef.get();
|
| + Activity activity = getActivity().get();
|
| if (activity == null) return false;
|
|
|
| if (isPermissionRevokedByPolicy(permission)) {
|
| @@ -275,7 +272,7 @@ public class ActivityWindowAndroid
|
| public boolean isPermissionRevokedByPolicy(String permission) {
|
| if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) return false;
|
|
|
| - Activity activity = mActivityRef.get();
|
| + Activity activity = getActivity().get();
|
| if (activity == null) return false;
|
|
|
| return activity.getPackageManager().isPermissionRevokedByPolicy(
|
| @@ -311,7 +308,7 @@ public class ActivityWindowAndroid
|
| private boolean requestPermissionsInternal(
|
| String[] permissions, PermissionCallback callback) {
|
| if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) return false;
|
| - Activity activity = mActivityRef.get();
|
| + Activity activity = getActivity().get();
|
| if (activity == null) return false;
|
|
|
| int requestCode = generateNextRequestCode();
|
|
|