Bug 1347583 - Allow third-party apps to open a tab in private browsing mode; r?sebastian draft
authorbrainbreaker <gautamprajapati06@gmail.com>
Mon, 24 Apr 2017 19:32:55 +0530
changeset 567164 bcf08274a759
parent 567163 62b649c6b314
child 625550 fa77c3ba1d47
push id55470
push userbmo:gautamprajapati06@gmail.com
push dateMon, 24 Apr 2017 14:06:32 +0000
reviewerssebastian
bugs1347583
milestone55.0a1
Bug 1347583 - Allow third-party apps to open a tab in private browsing mode; r?sebastian MozReview-Commit-ID: 6eM3E8qm9YE
mobile/android/base/java/org/mozilla/gecko/Tabs.java
--- a/mobile/android/base/java/org/mozilla/gecko/Tabs.java
+++ b/mobile/android/base/java/org/mozilla/gecko/Tabs.java
@@ -47,16 +47,17 @@ import android.support.v4.content.Contex
 import android.text.TextUtils;
 import android.util.Log;
 
 import static org.mozilla.gecko.Tab.TabType;
 
 public class Tabs implements BundleEventListener {
     private static final String LOGTAG = "GeckoTabs";
 
+    private static final String PRIVATE_TAB_INTENT_EXTRA = "private_tab";
     // mOrder and mTabs are always of the same cardinality, and contain the same values.
     private volatile CopyOnWriteArrayList<Tab> mOrder = new CopyOnWriteArrayList<Tab>();
 
     // A cache that maps a tab ID to an mOrder tab position.  All access should be synchronized.
     private final TabPositionCache tabPositionCache = new TabPositionCache();
 
     // All writes to mSelectedTab must be synchronized on the Tabs instance.
     // In general, it's preferred to always use selectTab()).
@@ -966,17 +967,17 @@ public class Tabs implements BundleEvent
                    final SafeIntent intent, final int flags) {
         final GeckoBundle data = new GeckoBundle();
         Tab tabToSelect = null;
         boolean delayLoad = (flags & LOADURL_DELAY_LOAD) != 0;
 
         // delayLoad implies background tab
         boolean background = delayLoad || (flags & LOADURL_BACKGROUND) != 0;
 
-        boolean isPrivate = (flags & LOADURL_PRIVATE) != 0;
+        boolean isPrivate = (flags & LOADURL_PRIVATE) != 0 || (intent != null && intent.getBooleanExtra(PRIVATE_TAB_INTENT_EXTRA, false));
         boolean userEntered = (flags & LOADURL_USER_ENTERED) != 0;
         boolean desktopMode = (flags & LOADURL_DESKTOP) != 0;
         boolean external = (flags & LOADURL_EXTERNAL) != 0;
         final boolean isFirstShownAfterActivityUnhidden = (flags & LOADURL_FIRST_AFTER_ACTIVITY_UNHIDDEN) != 0;
         final boolean customTab = (flags & LOADURL_CUSTOMTAB) != 0;
         final boolean webappTab = (flags & LOADURL_WEBAPP) != 0;
         final TabType type = customTab ? TabType.CUSTOMTAB :
             webappTab ? TabType.WEBAPP : TabType.BROWSING;