mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-17 23:35:34 +00:00
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:
parent
66f54a0378
commit
99c7d96804
@ -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)) {
|
||||
|
Loading…
Reference in New Issue
Block a user