bug 572249 - flush prefs on android app pause r=mwu

This commit is contained in:
Brad Lassey 2010-06-17 17:33:15 -04:00
parent 6a3f707030
commit 6b76e77b99
4 changed files with 20 additions and 0 deletions

View File

@ -151,6 +151,7 @@ abstract public class GeckoApp
@Override
public void onPause()
{
GeckoAppShell.sendEventToGecko(new GeckoEvent(GeckoEvent.ACTIVITY_PAUSING));
// The user is navigating away from this activity, but nothing
// has come to the foreground yet; for Gecko, we may want to
// stop repainting, for example.

View File

@ -64,6 +64,7 @@ public class GeckoEvent {
public static final int DRAW = 6;
public static final int SIZE_CHANGED = 7;
public static final int ACTIVITY_STOPPING = 8;
public static final int ACTIVITY_PAUSING = 9;
public static final int IME_BATCH_END = 0;
public static final int IME_BATCH_BEGIN = 1;

View File

@ -429,6 +429,7 @@ public:
DRAW = 6,
SIZE_CHANGED = 7,
ACTIVITY_STOPPING = 8,
ACTIVITY_PAUSING = 9,
dummy_java_enum_list_end
};

View File

@ -43,6 +43,7 @@
#include "nsIAppStartup.h"
#include "nsIGeolocationProvider.h"
#include "mozilla/Services.h"
#include "prenv.h"
#include "AndroidBridge.h"
@ -231,12 +232,28 @@ nsAppShell::ProcessNextNativeEvent(PRBool mayWait)
break;
case AndroidGeckoEvent::ACTIVITY_STOPPING: {
nsCOMPtr<nsIObserverService> obsServ =
mozilla::services::GetObserverService();
NS_NAMED_LITERAL_STRING(context, "shutdown-persist");
obsServ->NotifyObservers(nsnull, "quit-application-granted", nsnull);
obsServ->NotifyObservers(nsnull, "quit-application-forced", nsnull);
obsServ->NotifyObservers(nsnull, "quit-application", nsnull);
obsServ->NotifyObservers(nsnull, "profile-change-net-teardown", context.get());
obsServ->NotifyObservers(nsnull, "profile-change-teardown", context.get());
obsServ->NotifyObservers(nsnull, "profile-before-change", context.get());
nsCOMPtr<nsIAppStartup> appSvc = do_GetService("@mozilla.org/toolkit/app-startup;1");
if (appSvc)
appSvc->Quit(nsIAppStartup::eForceQuit);
break;
}
case AndroidGeckoEvent::ACTIVITY_PAUSING: {
nsCOMPtr<nsIObserverService> obsServ =
mozilla::services::GetObserverService();
obsServ->NotifyObservers(nsnull, "profile-before-change", nsnull);
break;
}
default:
if (target)
target->OnAndroidEvent(curEvent);