Revert to addb9a82a6b8 (undo my failed backouts)
authorMatt Brubeck <mbrubeck@mozilla.com>
Wed, 09 Nov 2011 17:31:09 -0800
changeset 83428 a2f776f67fa1b42875c4f2c0ba773fc8320693d6
parent 83427 24cbdc53a4ee9b185f084265b63eda983046f06c
child 83429 eaf778e88070a0292cf3c35139686eac4fe307ca
push id519
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 00:38:35 +0000
treeherdermozilla-beta@788ea1ef610b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone10.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Revert to addb9a82a6b8 (undo my failed backouts)
embedding/android/GeckoApp.java
embedding/android/GeckoAppShell.java
embedding/android/resources/layout/gecko_menu.xml
mobile/chrome/content/browser.js
other-licenses/android/APKOpen.cpp
toolkit/xre/nsAndroidStartup.cpp
--- a/embedding/android/GeckoApp.java
+++ b/embedding/android/GeckoApp.java
@@ -483,19 +483,19 @@ abstract public class GeckoApp
     }
 
     @Override
     public boolean onOptionsItemSelected(MenuItem item) {
         Tab tab = null;
         Tab.HistoryEntry he = null;
         Intent intent = null;
         switch (item.getItemId()) {
-           case R.id.quit:
-               quit();
-               return true;
+            case R.id.quit:
+               GeckoAppShell.sendEventToGecko(new GeckoEvent("Browser:Quit", null));
+                return true;
            case R.id.bookmark:
                tab = Tabs.getInstance().getSelectedTab();
                if (tab != null) {
                    if (item.isChecked()) {
                        tab.removeBookmark();
                        Toast.makeText(this, R.string.bookmark_removed, Toast.LENGTH_SHORT).show();
                        item.setIcon(R.drawable.ic_menu_bookmark_add);
                        item.setTitle(R.string.bookmark_add);
@@ -587,24 +587,16 @@ abstract public class GeckoApp
                 if (Tabs.getInstance().isSelectedTab(tab))
                     mBrowserToolbar.setFavicon(tab.getFavicon());
 
                 onTabsChanged();
             }
         });
     }
 
-    private void quit() {
-        Log.i(LOG_NAME, "pleaseKillMe");
-        rememberLastScreen(true);
-        GeckoAppShell.nativeQuit();
-        finish();
-        System.exit(0);
-    }
-
     void handleLocationChange(final int tabId, final String uri) {
         final Tab tab = Tabs.getInstance().getTab(tabId);
         if (tab == null)
             return;
         
         String oldBaseURI = tab.getURL();
         tab.updateURL(uri);
 
@@ -1245,16 +1237,17 @@ abstract public class GeckoApp
             Log.i(LOG_NAME,"Intent : BOOKMARK - " + args);
         }
     }
 
     @Override
     public void onPause()
     {
         Log.i(LOG_NAME, "pause");
+        rememberLastScreen(false);
 
         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.
 
         // Whatever we do here should be fast, because we're blocking
         // the next activity from showing up until we finish.
@@ -1557,17 +1550,17 @@ abstract public class GeckoApp
     public void onBackPressed() {
         if (mFullScreen) {
             GeckoAppShell.sendEventToGecko(new GeckoEvent("FullScreen:Exit", null));
             return;
         }
 
         Tab tab = Tabs.getInstance().getSelectedTab();
         if (tab == null || !tab.doBack()) {
-            finish();
+            moveTaskToBack(true);
         }
     }
 
     static int kCaptureIndex = 0;
 
     @Override
     protected void onActivityResult(int requestCode, int resultCode,
                                     Intent data) {
--- a/embedding/android/GeckoAppShell.java
+++ b/embedding/android/GeckoAppShell.java
@@ -111,17 +111,16 @@ public class GeckoAppShell
 
     private static HashMap<String, ArrayList<GeckoEventListener>> mEventListeners;
 
     /* The Android-side API: API methods that Android calls */
 
     // Initialization methods
     public static native void nativeInit();
     public static native void nativeRun(String args);
-    public static native void nativeQuit();
 
     // helper methods
     public static native void setSurfaceView(GeckoSurfaceView sv);
     public static native void putenv(String map);
     public static native void onResume();
     public static native void onLowMemory();
     public static native void callObserver(String observerKey, String topic, String data);
     public static native void removeObserver(String observerKey);
@@ -701,17 +700,24 @@ public class GeckoAppShell
         GeckoApp.setLaunchState(GeckoApp.LaunchState.GeckoExiting);
         Log.i("GeckoAppJava", "XRE exited");
         if (gRestartScheduled) {
             GeckoApp.mAppContext.doRestart();
         } else {
             Log.i("GeckoAppJava", "we're done, good bye");
             GeckoApp.mAppContext.finish();
         }
-        System.exit(0);
+        getHandler().postDelayed(new Runnable() {
+            // This is just a watch dog to make sure we die
+            // we should never hit this
+            public void run() {
+                Log.w("GeckoAppShell", "Killing via System.exit()");
+                System.exit(0);
+            }
+        }, 5000);
     }
     static void scheduleRestart() {
         Log.i("GeckoAppJava", "scheduling restart");
         gRestartScheduled = true;
     }
 
     // "Installs" an application by creating a shortcut
     static void createShortcut(String aTitle, String aURI, String aIconData, String aType) {
--- a/embedding/android/resources/layout/gecko_menu.xml
+++ b/embedding/android/resources/layout/gecko_menu.xml
@@ -25,10 +25,10 @@
 
     <item android:id="@+id/preferences"
           android:title="@string/preferences" />
 
     <item android:id="@+id/addons"
           android:title="@string/addons"/>
 
     <item android:id="@+id/quit"
-          android:title="@string/quit"/>
+          android:title="@string/quit" />
 </menu>
--- a/mobile/chrome/content/browser.js
+++ b/mobile/chrome/content/browser.js
@@ -136,16 +136,17 @@ var BrowserApp = {
     Services.obs.addObserver(this, "Tab:Add", false);
     Services.obs.addObserver(this, "Tab:Load", false);
     Services.obs.addObserver(this, "Tab:Select", false);
     Services.obs.addObserver(this, "Tab:Close", false);
     Services.obs.addObserver(this, "Session:Back", false);
     Services.obs.addObserver(this, "Session:Forward", false);
     Services.obs.addObserver(this, "Session:Reload", false);
     Services.obs.addObserver(this, "SaveAs:PDF", false);
+    Services.obs.addObserver(this, "Browser:Quit", false);
     Services.obs.addObserver(this, "Preferences:Get", false);
     Services.obs.addObserver(this, "Preferences:Set", false);
     Services.obs.addObserver(this, "ScrollTo:FocusedInput", false);
     Services.obs.addObserver(this, "Sanitize:ClearAll", false);
     Services.obs.addObserver(this, "FullScreen:Exit", false);
 
     Services.obs.addObserver(XPInstallObserver, "addon-install-blocked", false);
     Services.obs.addObserver(XPInstallObserver, "addon-install-started", false);
@@ -290,16 +291,21 @@ var BrowserApp = {
           tabID: aTab.id
         }
       };
 
       sendMessageToJava(message);
     }
   },
 
+  quit: function quit() {
+      window.QueryInterface(Ci.nsIDOMChromeWindow).minimize();
+      window.close();
+  },
+
   saveAsPDF: function saveAsPDF(aBrowser) {
     // Create the final destination file location
     let ContentAreaUtils = {};
     Services.scriptloader.loadSubScript("chrome://global/content/contentAreaUtils.js", ContentAreaUtils);
     let fileName = ContentAreaUtils.getDefaultFileName(aBrowser.contentTitle, aBrowser.documentURI, null, null);
     fileName = fileName.trim() + ".pdf";
 
     let dm = Cc["@mozilla.org/download-manager;1"].getService(Ci.nsIDownloadManager);
@@ -529,16 +535,18 @@ var BrowserApp = {
       newTab.active = true;
     } else if (aTopic == "Tab:Load") {
       let uri = URIFixup.createFixupURI(aData, Ci.nsIURIFixup.FIXUP_FLAG_ALLOW_KEYWORD_LOOKUP);
       browser.loadURI(uri ? uri.spec : aData);
     } else if (aTopic == "Tab:Select") {
       this.selectTab(this.getTabForId(parseInt(aData)));
     } else if (aTopic == "Tab:Close") {
       this.closeTab(this.getTabForId(parseInt(aData)));
+    } else if (aTopic == "Browser:Quit") {
+      this.quit();
     } else if (aTopic == "SaveAs:PDF") {
       this.saveAsPDF(browser);
     } else if (aTopic == "Preferences:Get") {
       this.getPreferences(aData);
     } else if (aTopic == "Preferences:Set") {
       this.setPreferences(aData);
     } else if (aTopic == "ScrollTo:FocusedInput") {
       this.scrollToFocusedInput(browser);
--- a/other-licenses/android/APKOpen.cpp
+++ b/other-licenses/android/APKOpen.cpp
@@ -225,17 +225,16 @@ static name ## _t f_ ## name; \
 extern "C" NS_EXPORT void JNICALL \
 Java_org_mozilla_gecko_GeckoAppShell_ ## name(JNIEnv *jenv, jclass jc, type1 one, type2 two, type3 three) \
 { \
   f_ ## name(jenv, jc, one, two, three); \
 }
 
 SHELL_WRAPPER0(nativeInit)
 SHELL_WRAPPER1(nativeRun, jstring)
-SHELL_WRAPPER0(nativeQuit)
 SHELL_WRAPPER1(notifyGeckoOfEvent, jobject)
 SHELL_WRAPPER0(processNextNativeEvent)
 SHELL_WRAPPER1(setSurfaceView, jobject)
 SHELL_WRAPPER0(onResume)
 SHELL_WRAPPER0(onLowMemory)
 SHELL_WRAPPER3(callObserver, jstring, jstring, jstring)
 SHELL_WRAPPER1(removeObserver, jstring)
 SHELL_WRAPPER1(onChangeNetworkLinkStatus, jstring)
@@ -633,17 +632,16 @@ loadLibs(const char *apkName)
 #endif
 
   if (!xul_handle)
     __android_log_print(ANDROID_LOG_ERROR, "GeckoLibLoad", "Couldn't get a handle to libxul!");
 
 #define GETFUNC(name) f_ ## name = (name ## _t) __wrap_dlsym(xul_handle, "Java_org_mozilla_gecko_GeckoAppShell_" #name)
   GETFUNC(nativeInit);
   GETFUNC(nativeRun);
-  GETFUNC(nativeQuit);
   GETFUNC(notifyGeckoOfEvent);
   GETFUNC(processNextNativeEvent);
   GETFUNC(setSurfaceView);
   GETFUNC(onResume);
   GETFUNC(onLowMemory);
   GETFUNC(callObserver);
   GETFUNC(removeObserver);
   GETFUNC(onChangeNetworkLinkStatus);
--- a/toolkit/xre/nsAndroidStartup.cpp
+++ b/toolkit/xre/nsAndroidStartup.cpp
@@ -49,18 +49,16 @@
 
 #include "nsTArray.h"
 #include "nsString.h"
 #include "nsILocalFile.h"
 #include "nsAppRunner.h"
 #include "AndroidBridge.h"
 #include "APKOpen.h"
 #include "nsExceptionHandler.h"
-#include "nsIAppStartup.h"
-#include "nsToolkitCompsCID.h"
 
 #define LOG(args...) __android_log_print(ANDROID_LOG_INFO, MOZ_APP_NAME, args)
 
 #define _STR(s) # s
 #define STR(s) _STR(s)
 
 struct AutoAttachJavaThread {
     AutoAttachJavaThread() {
@@ -165,16 +163,8 @@ Java_org_mozilla_gecko_GeckoAppShell_nat
     int len = jenv->GetStringLength(jargs);
     wargs.SetLength(jenv->GetStringLength(jargs));
     jenv->GetStringRegion(jargs, 0, len, wargs.BeginWriting());
     char *args = ToNewUTF8String(wargs);
 
     GeckoStart(args);
 }
 
-extern "C" NS_EXPORT void JNICALL
-Java_org_mozilla_gecko_GeckoAppShell_nativeQuit(JNIEnv*, jclass)
-{
-    nsCOMPtr<nsIAppStartup> appStartup =
-        do_GetService(NS_APPSTARTUP_CONTRACTID);
-    if (appStartup)
-        appStartup->Quit(nsIAppStartup::eAttemptQuit);
-}