Bug 1252650 - Add GeckoThread.canUseProfile; r=snorp

canUseProfile returns whether we're currently using the given profile or
we can potentially start Gecko with the given profile.
This commit is contained in:
Jim Chen 2016-04-20 15:06:13 -04:00
parent 66f54a0378
commit 99c7d96804

View File

@ -130,17 +130,10 @@ public class GeckoThread extends Thread {
return false;
}
public static boolean initWithProfile(String profileName, File profileDir) {
if (profileName == null) {
throw new IllegalArgumentException("Null profile name");
}
final GeckoProfile profile = getActiveProfile();
private static boolean canUseProfile(final GeckoProfile profile, final String profileName,
final File profileDir) {
if (profile == null) {
// We haven't initialized yet; okay to initialize now.
final Context context = GeckoAppShell.getApplicationContext();
return init(GeckoProfile.get(context, profileName, profileDir),
/* args */ null, /* action */ null, /* debugging */ false);
return true;
}
// We already initialized and have a profile; see if it matches ours.
@ -153,6 +146,29 @@ public class GeckoThread extends Thread {
}
}
public static boolean canUseProfile(final String profileName, final File profileDir) {
if (profileName == null) {
throw new IllegalArgumentException("Null profile name");
}
return canUseProfile(getActiveProfile(), profileName, profileDir);
}
public static boolean initWithProfile(final String profileName, final File profileDir) {
if (profileName == null) {
throw new IllegalArgumentException("Null profile name");
}
final GeckoProfile profile = getActiveProfile();
if (profile != null) {
return canUseProfile(profile, profileName, profileDir);
}
// We haven't initialized yet; okay to initialize now.
final Context context = GeckoAppShell.getApplicationContext();
return init(GeckoProfile.get(context, profileName, profileDir),
/* args */ null, /* action */ null, /* debugging */ false);
}
public static boolean launch() {
ThreadUtils.assertOnUiThread();
if (checkAndSetState(State.INITIAL, State.LAUNCHED)) {