From 6b76e77b9937372b7557fa073ce4e09255c62ced Mon Sep 17 00:00:00 2001 From: Brad Lassey Date: Thu, 17 Jun 2010 17:33:15 -0400 Subject: [PATCH] bug 572249 - flush prefs on android app pause r=mwu --- embedding/android/GeckoApp.java | 1 + embedding/android/GeckoEvent.java | 1 + widget/src/android/AndroidJavaWrappers.h | 1 + widget/src/android/nsAppShell.cpp | 17 +++++++++++++++++ 4 files changed, 20 insertions(+) diff --git a/embedding/android/GeckoApp.java b/embedding/android/GeckoApp.java index be74d76f74a1..53b77394b6f9 100644 --- a/embedding/android/GeckoApp.java +++ b/embedding/android/GeckoApp.java @@ -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. diff --git a/embedding/android/GeckoEvent.java b/embedding/android/GeckoEvent.java index 5538fe376406..debc1452b181 100644 --- a/embedding/android/GeckoEvent.java +++ b/embedding/android/GeckoEvent.java @@ -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; diff --git a/widget/src/android/AndroidJavaWrappers.h b/widget/src/android/AndroidJavaWrappers.h index 2797ac85a12d..7f69503be5df 100644 --- a/widget/src/android/AndroidJavaWrappers.h +++ b/widget/src/android/AndroidJavaWrappers.h @@ -429,6 +429,7 @@ public: DRAW = 6, SIZE_CHANGED = 7, ACTIVITY_STOPPING = 8, + ACTIVITY_PAUSING = 9, dummy_java_enum_list_end }; diff --git a/widget/src/android/nsAppShell.cpp b/widget/src/android/nsAppShell.cpp index b160f73ca55c..cc5355d2468e 100644 --- a/widget/src/android/nsAppShell.cpp +++ b/widget/src/android/nsAppShell.cpp @@ -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 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 appSvc = do_GetService("@mozilla.org/toolkit/app-startup;1"); if (appSvc) appSvc->Quit(nsIAppStartup::eForceQuit); break; } + case AndroidGeckoEvent::ACTIVITY_PAUSING: { + nsCOMPtr obsServ = + mozilla::services::GetObserverService(); + obsServ->NotifyObservers(nsnull, "profile-before-change", nsnull); + break; + } + default: if (target) target->OnAndroidEvent(curEvent);