Back out 150b57fca97c, 22f16ec4052a, 03c53ee42fc9
authorMatt Brubeck <mbrubeck@mozilla.com>
Wed, 09 Nov 2011 16:06:20 -0800
changeset 83425 d34b5885abe8f7619b48cbca46e73c1d2e6ed362
parent 83424 e66ab555b3228559bf039e11e1147bb5937593c9
child 83426 9bffa9a8cfe450986a53f6c5a45fe29ebfcd54ca
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
backs out150b57fca97cb0f558ab054f425a0e99f65aef35
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
Back out 150b57fca97c, 22f16ec4052a, 03c53ee42fc9 * * * Back out 03c53ee42fc9 on suspicion of causing talos failures
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:
-               GeckoAppShell.sendEventToGecko(new GeckoEvent("Browser:Quit", null));
-                return true;
+           case R.id.quit:
+               quit();
+               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,16 +587,24 @@ 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);
 
@@ -1237,17 +1245,16 @@ 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.
--- a/embedding/android/GeckoAppShell.java
+++ b/embedding/android/GeckoAppShell.java
@@ -111,16 +111,17 @@ 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);
@@ -700,24 +701,17 @@ 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();
         }
-        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);
+        System.exit(0);
     }
     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
@@ -24,11 +24,14 @@
           android:title="@string/save_as_pdf" />
 
     <item android:id="@+id/preferences"
           android:title="@string/preferences" />
 
     <item android:id="@+id/addons"
           android:title="@string/addons"/>
 
+    <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,17 +136,16 @@ 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);
@@ -291,21 +290,16 @@ 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);
@@ -535,18 +529,16 @@ 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,16 +225,17 @@ 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)
@@ -632,16 +633,17 @@ 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,16 +49,18 @@
 
 #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() {
@@ -163,8 +165,16 @@ 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);
+}