Backed out changeset a2c46d6880e2 (bug 1269682) for robocop bustage a=backout
authorWes Kocher <wkocher@mozilla.com>
Tue, 24 May 2016 14:12:56 -0700
changeset 333005 9c28c3b843d9ecfb64dfee69469d01e255a73cff
parent 333004 bcac6066d9267ca2ea7b281cfcf2223450435a5e
child 333006 6eed58568de0192182a682e718c23b0d0507cbad
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbackout
bugs1269682
milestone48.0a2
backs outa2c46d6880e2ae4488c657c58c4bf71ece9d4433
Backed out changeset a2c46d6880e2 (bug 1269682) for robocop bustage a=backout
mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
mobile/android/base/java/org/mozilla/gecko/GeckoProfile.java
--- a/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
@@ -304,18 +304,16 @@ public class BrowserApp extends GeckoApp
     private boolean mHideWebContentOnAnimationEnd;
 
     private final DynamicToolbar mDynamicToolbar = new DynamicToolbar();
     private final ScreenshotObserver mScreenshotObserver = new ScreenshotObserver();
 
     @NonNull
     private SearchEngineManager searchEngineManager; // Contains reference to Context - DO NOT LEAK!
 
-    private boolean mHasResumed;
-
     @Override
     public View onCreateView(final String name, final Context context, final AttributeSet attrs) {
         final View view;
         if (BrowserToolbar.class.getName().equals(name)) {
             view = BrowserToolbar.create(context, attrs);
         } else if (TabsPanel.TabsLayout.class.getName().equals(name)) {
             view = TabsPanel.createTabsLayout(context, attrs);
         } else {
@@ -1082,22 +1080,30 @@ public class BrowserApp extends GeckoApp
         super.onResume();
         if (mIsAbortingAppLaunch) {
             return;
         }
 
         // Needed for Adjust to get accurate session measurements
         AdjustConstants.getAdjustHelper().onResume();
 
-        if (!mHasResumed) {
-            EventDispatcher.getInstance().unregisterGeckoThreadListener((GeckoEventListener) this,
-                    "Prompt:ShowTop");
-            mHasResumed = true;
+        final String args = ContextUtils.getStringExtra(getIntent(), "args");
+        // If an external intent tries to start Fennec in guest mode, and it's not already
+        // in guest mode, this will change modes before opening the url.
+        // NOTE: OnResume is called twice sometimes when showing on the lock screen.
+        final boolean enableGuestSession = GuestSession.shouldUse(this, args);
+        final boolean inGuestSession = GeckoProfile.get(this).inGuestMode();
+        if (enableGuestSession != inGuestSession) {
+            doRestart(getIntent());
+            return;
         }
 
+        EventDispatcher.getInstance().unregisterGeckoThreadListener((GeckoEventListener) this,
+            "Prompt:ShowTop");
+
         processTabQueue();
 
         mScreenshotObserver.start();
 
         mAddToHomeScreenPromotion.resume();
     }
 
     @Override
@@ -1105,22 +1111,19 @@ public class BrowserApp extends GeckoApp
         super.onPause();
         if (mIsAbortingAppLaunch) {
             return;
         }
 
         // Needed for Adjust to get accurate session measurements
         AdjustConstants.getAdjustHelper().onPause();
 
-        if (mHasResumed) {
-            // Register for Prompt: so we can foreground this activity even if it's hidden.
-            EventDispatcher.getInstance().registerGeckoThreadListener((GeckoEventListener) this,
-                "Prompt:");
-            mHasResumed = false;
-        }
+        // Register for Prompt:ShowTop so we can foreground this activity even if it's hidden.
+        EventDispatcher.getInstance().registerGeckoThreadListener((GeckoEventListener) this,
+                "Prompt:ShowTop");
 
         mScreenshotObserver.stop();
 
         mAddToHomeScreenPromotion.pause();
     }
 
     @Override
     public void onRestart() {
--- a/mobile/android/base/java/org/mozilla/gecko/GeckoProfile.java
+++ b/mobile/android/base/java/org/mozilla/gecko/GeckoProfile.java
@@ -110,24 +110,24 @@ public final class GeckoProfile {
         UNLOCKED,
         UNDEFINED
     };
 
     /**
      * Can return null.
      */
     public static GeckoProfile getFromArgs(final Context context, final String args) {
+        if (args == null) {
+            return null;
+        }
+
         if (GuestSession.shouldUse(context, args)) {
             return GeckoProfile.getOrCreateGuestProfile(context);
         }
 
-        if (args == null) {
-            return null;
-        }
-
         String profileName = null;
         String profilePath = null;
         if (args.contains("-P")) {
             final Pattern p = Pattern.compile("(?:-P\\s*)(\\w*)(\\s*)");
             final Matcher m = p.matcher(args);
             if (m.find()) {
                 profileName = m.group(1);
             }