Bug 859391 - Disable session restore in webapps. r=bnicholson

This commit is contained in:
Wes Johnston 2013-04-18 17:19:10 -07:00
Родитель 234afb43c8
Коммит 5dd3cc7663
2 изменённых файлов: 22 добавлений и 14 удалений

Просмотреть файл

@ -1405,9 +1405,8 @@ abstract public class GeckoApp
// check if the last run was exited due to a normal kill while
// we were in the background, or a more harsh kill while we were
// active
if (savedInstanceState != null) {
mRestoreMode = RESTORE_OOM;
mRestoreMode = getSessionRestoreState(savedInstanceState);
if (mRestoreMode == RESTORE_OOM) {
boolean wasInBackground =
savedInstanceState.getBoolean(SAVED_STATE_IN_BACKGROUND, false);
@ -1477,10 +1476,6 @@ abstract public class GeckoApp
passedUri = uri;
}
if (mRestoreMode == RESTORE_NONE && shouldRestoreSession()) {
mRestoreMode = RESTORE_CRASH;
}
final boolean isExternalURL = passedUri != null && !passedUri.equals("about:home");
StartupAction startupAction;
if (isExternalURL) {
@ -1714,20 +1709,32 @@ abstract public class GeckoApp
return mProfile;
}
protected boolean shouldRestoreSession() {
SharedPreferences prefs = GeckoApp.mAppContext.getSharedPreferences(PREFS_NAME, 0);
protected int getSessionRestoreState(Bundle savedInstanceState) {
if (savedInstanceState != null) {
return RESTORE_OOM;
}
final SharedPreferences prefs = GeckoApp.mAppContext.getSharedPreferences(PREFS_NAME, 0);
// We record crashes in the crash reporter. If sessionstore.js
// exists, but we didn't flag a crash in the crash reporter, we
// were probably just force killed by the user, so we shouldn't do
// a restore.
if (prefs.getBoolean(PREFS_CRASHED, false)) {
prefs.edit().putBoolean(GeckoApp.PREFS_CRASHED, false).commit();
ThreadUtils.postToBackgroundThread(new Runnable() {
@Override
public void run() {
prefs.edit()
.putBoolean(GeckoApp.PREFS_CRASHED, false)
.commit();
}
});
if (getProfile().shouldRestoreSession()) {
return true;
return RESTORE_CRASH;
}
}
return false;
return RESTORE_NONE;
}
/**

Просмотреть файл

@ -148,8 +148,9 @@ public class WebAppImpl extends GeckoApp {
}
@Override
protected boolean shouldRestoreSession() {
return false;
protected int getSessionRestoreState(Bundle savedInstanceState) {
// for now webapps never restore your session
return RESTORE_NONE;
}
@Override