Bug 1192346 - RestrictedProfiles: If no GeckoInterface instance is available, try to get GeckoProfile from context. r=mhaigh, a=sledru
authorSebastian Kaspari <s.kaspari@gmail.com>
Tue, 11 Aug 2015 16:12:31 +0200
changeset 288759 ebcd3c379b1c2eb9b5a32f10f4d3b03b7210321c
parent 288758 5b24d4b40792fdc3e3f6e6f1848296f901f3d67e
child 288760 5ae2ab4052b8d27ed04bcc8a6764d77882ffbb99
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmhaigh, sledru
bugs1192346
milestone42.0a2
Bug 1192346 - RestrictedProfiles: If no GeckoInterface instance is available, try to get GeckoProfile from context. r=mhaigh, a=sledru
mobile/android/base/RestrictedProfiles.java
--- a/mobile/android/base/RestrictedProfiles.java
+++ b/mobile/android/base/RestrictedProfiles.java
@@ -36,27 +36,32 @@ public class RestrictedProfiles {
     }
 
     public static synchronized RestrictionConfiguration createConfiguration(Context context) {
         if (configuration != null) {
             // This method is synchronized and another thread might already have created the configuration.
             return configuration;
         }
 
-        if (isGuestProfile()) {
+        if (isGuestProfile(context)) {
             return new GuestProfileConfiguration();
         } else if(isRestrictedProfile(context)) {
             return new RestrictedProfileConfiguration(context);
         } else {
             return new DefaultConfiguration();
         }
     }
 
-    private static boolean isGuestProfile() {
-        return GeckoAppShell.getGeckoInterface().getProfile().inGuestMode();
+    private static boolean isGuestProfile(Context context) {
+        GeckoAppShell.GeckoInterface geckoInterface = GeckoAppShell.getGeckoInterface();
+        if (geckoInterface != null) {
+            return geckoInterface.getProfile().inGuestMode();
+        }
+
+        return GeckoProfile.get(context).inGuestMode();
     }
 
     @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
     public static boolean isRestrictedProfile(Context context) {
         if (Versions.preJBMR2) {
             // Early versions don't support restrictions at all
             return false;
         }