Bug 1192346 - RestrictedProfiles: If no GeckoInterface instance is available, try to get GeckoProfile from context. r=mhaigh
authorSebastian Kaspari <s.kaspari@gmail.com>
Tue, 11 Aug 2015 16:12:31 +0200
changeset 289960 10cab33e893c8627c02ecfe3dfdae94f5fea84f1
parent 289959 41520f8116c0ce5a80efc51e04f1af749205e648
child 289961 8584e1ea8f6ac747d828cc2604cfc34a680ff95b
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmhaigh
bugs1192346
milestone43.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1192346 - RestrictedProfiles: If no GeckoInterface instance is available, try to get GeckoProfile from context. r=mhaigh
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;
         }