| 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.Context; | 9 import android.content.Context; |
| 10 import android.content.Intent; | 10 import android.content.Intent; |
| 11 import android.content.pm.PackageManager; | 11 import android.content.pm.PackageManager; |
| 12 import android.os.Process; | 12 import android.os.Process; |
| 13 | 13 |
| 14 import org.chromium.base.ActivityState; | 14 import org.chromium.base.ActivityState; |
| 15 import org.chromium.base.ApiCompatibilityUtils; | 15 import org.chromium.base.ApiCompatibilityUtils; |
| 16 import org.chromium.base.ApplicationStatus; | 16 import org.chromium.base.ApplicationStatus; |
| 17 import org.chromium.base.Callback; | 17 import org.chromium.base.Callback; |
| 18 import org.chromium.ui.base.AndroidPermissionDelegate; | 18 import org.chromium.ui.base.AndroidPermissionDelegate; |
| 19 import org.chromium.ui.base.WindowAndroid; | 19 import org.chromium.ui.base.WindowAndroid; |
| 20 import org.chromium.ui.display.DisplayAndroid; |
| 20 | 21 |
| 21 import java.lang.ref.WeakReference; | 22 import java.lang.ref.WeakReference; |
| 22 import java.util.Arrays; | 23 import java.util.Arrays; |
| 23 | 24 |
| 24 /** | 25 /** |
| 25 * The class provides the WindowAndroid's implementation which requires Activity
Instance. It is | 26 * The class provides the WindowAndroid's implementation which requires Activity
Instance. It is |
| 26 * only intended to be used when in VR. | 27 * only intended to be used when in VR. |
| 27 */ | 28 */ |
| 28 public class VrWindowAndroid | 29 public class VrWindowAndroid extends WindowAndroid |
| 29 extends WindowAndroid | |
| 30 implements ApplicationStatus.ActivityStateListener { | 30 implements ApplicationStatus.ActivityStateListener { |
| 31 | 31 |
| 32 public VrWindowAndroid(Context context) { | 32 public VrWindowAndroid(Context context, DisplayAndroid display) { |
| 33 super(context); | 33 super(context, display); |
| 34 Activity activity = activityFromContext(context); | 34 Activity activity = activityFromContext(context); |
| 35 if (activity == null) { | 35 if (activity == null) { |
| 36 throw new IllegalArgumentException("Context is not and does not wrap
an Activity"); | 36 throw new IllegalArgumentException("Context is not and does not wrap
an Activity"); |
| 37 } | 37 } |
| 38 ApplicationStatus.registerStateListenerForActivity(this, activity); | 38 ApplicationStatus.registerStateListenerForActivity(this, activity); |
| 39 setAndroidPermissionDelegate(new ActivityAndroidPermissionDelegate()); | 39 setAndroidPermissionDelegate(new ActivityAndroidPermissionDelegate()); |
| 40 } | 40 } |
| 41 | 41 |
| 42 // TODO(mthiesse): How do we want to handle intents that might kick us out o
f VR? | 42 // TODO(mthiesse): How do we want to handle intents that might kick us out o
f VR? |
| 43 @Override | 43 @Override |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 | 97 |
| 98 @Override | 98 @Override |
| 99 public void requestPermissions( | 99 public void requestPermissions( |
| 100 final String[] permissions, final PermissionCallback callback) { | 100 final String[] permissions, final PermissionCallback callback) { |
| 101 int[] grantResults = new int[permissions.length]; | 101 int[] grantResults = new int[permissions.length]; |
| 102 Arrays.fill(grantResults, PackageManager.PERMISSION_DENIED); | 102 Arrays.fill(grantResults, PackageManager.PERMISSION_DENIED); |
| 103 callback.onRequestPermissionsResult(permissions, grantResults); | 103 callback.onRequestPermissionsResult(permissions, grantResults); |
| 104 } | 104 } |
| 105 } | 105 } |
| 106 } | 106 } |
| OLD | NEW |