Bug 888482 - Make sure default profile exists when starting Gecko; r=snorp

This commit is contained in:
Jim Chen 2014-09-30 18:20:59 -04:00
parent 6bac281a30
commit 30d276c56c

View File

@ -136,25 +136,29 @@ public class GeckoThread extends Thread implements GeckoEventListener {
}
private String addCustomProfileArg(String args) {
String profile = "";
String guest = "";
String profileArg = "";
String guestArg = "";
if (GeckoAppShell.getGeckoInterface() != null) {
if (GeckoAppShell.getGeckoInterface().getProfile().inGuestMode()) {
final GeckoProfile profile = GeckoAppShell.getGeckoInterface().getProfile();
if (profile.inGuestMode()) {
try {
profile = " -profile " + GeckoAppShell.getGeckoInterface().getProfile().getDir().getCanonicalPath();
} catch (IOException ioe) { Log.e(LOGTAG, "error getting guest profile path", ioe); }
profileArg = " -profile " + profile.getDir().getCanonicalPath();
} catch (final IOException ioe) {
Log.e(LOGTAG, "error getting guest profile path", ioe);
}
if (args == null || !args.contains(BrowserApp.GUEST_BROWSING_ARG)) {
guest = " " + BrowserApp.GUEST_BROWSING_ARG;
guestArg = " " + BrowserApp.GUEST_BROWSING_ARG;
}
} else if (!GeckoProfile.sIsUsingCustomProfile) {
// If nothing was passed in in the intent, force Gecko to use the default profile for
// for this activity
profile = " -P " + GeckoAppShell.getGeckoInterface().getProfile().getName();
// If nothing was passed in the intent, make sure the default profile exists and
// force Gecko to use the default profile for this activity
profileArg = " -P " + profile.forceCreate().getName();
}
}
return (args != null ? args : "") + profile + guest;
return (args != null ? args : "") + profileArg + guestArg;
}
@Override