예제 #1
0
  public static GeckoProfile get(Context context) {
    boolean isGeckoApp = false;
    try {
      isGeckoApp = context instanceof GeckoApp;
    } catch (NoClassDefFoundError ex) {
    }

    if (isGeckoApp) {
      // Check for a cached profile on this context already
      // TODO: We should not be caching profile information on the Activity context
      if (((GeckoApp) context).mProfile != null) {
        return ((GeckoApp) context).mProfile;
      }
    }

    // If the guest profile exists and is locked, return it
    GeckoProfile guest = GeckoProfile.getGuestProfile(context);
    if (guest != null && guest.locked()) {
      return guest;
    }

    if (isGeckoApp) {
      // Otherwise, get the default profile for the Activity
      return get(context, ((GeckoApp) context).getDefaultProfileName());
    }

    return get(context, "");
  }
예제 #2
0
  public static boolean maybeCleanupGuestProfile(final Context context) {
    final GeckoProfile profile = getGuestProfile(context);

    if (profile == null) {
      return false;
    } else if (!profile.locked()) {
      profile.mInGuestMode = false;

      // If the guest dir exists, but it's unlocked, delete it
      removeGuestProfile(context);

      return true;
    }
    return false;
  }
예제 #3
0
  public static GeckoProfile get(Context context) {
    boolean isGeckoApp = false;
    try {
      isGeckoApp = context instanceof GeckoApp;
    } catch (NoClassDefFoundError ex) {
    }

    if (isGeckoApp) {
      // Check for a cached profile on this context already
      // TODO: We should not be caching profile information on the Activity context
      final GeckoApp geckoApp = (GeckoApp) context;
      if (geckoApp.mProfile != null) {
        return geckoApp.mProfile;
      }
    }

    // If the guest profile exists and is locked, return it
    GeckoProfile guest = GeckoProfile.getGuestProfile(context);
    if (guest != null && guest.locked()) {
      return guest;
    }

    if (isGeckoApp) {
      final GeckoApp geckoApp = (GeckoApp) context;
      String defaultProfileName;
      try {
        defaultProfileName = geckoApp.getDefaultProfileName();
      } catch (NoMozillaDirectoryException e) {
        // If this failed, we're screwed. But there are so many callers that
        // we'll just throw a RuntimeException.
        Log.wtf(LOGTAG, "Unable to get default profile name.", e);
        throw new RuntimeException(e);
      }
      // Otherwise, get the default profile for the Activity.
      return get(context, defaultProfileName);
    }

    return get(context, "");
  }