Bug 1347583 - Allow third-party apps to open a tab in private browsing mode; r?sebastian draft
authorbrainbreaker <gautamprajapati06@gmail.com>
Sat, 22 Apr 2017 01:07:57 +0530
changeset 566571 541357a18badad08bb7cbb50df95cb7f972148b2
parent 566524 ff6abe20041933a67f636b748ed698e9616a6833
child 625350 9d27d0169f6388e6d6b4148a15acb034067365eb
push id55256
push userbmo:gautamprajapati06@gmail.com
push dateFri, 21 Apr 2017 19:40:13 +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,18 @@ 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;
+        final boolean isPrivate = 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;
@@ -986,16 +988,19 @@ public class Tabs implements BundleEvent
         data.putInt("parentId", parentId);
         data.putBoolean("userEntered", userEntered);
         data.putBoolean("isPrivate", isPrivate);
         data.putBoolean("pinned", (flags & LOADURL_PINNED) != 0);
         data.putBoolean("desktopMode", desktopMode);
         data.putString("tabType", type.name());
 
         final boolean needsNewTab;
+        if (intent == null) {
+            Log.e("nfdjnfdfdh","fdjhbfhdbfd");
+        }
         final String applicationId = (intent == null) ? null :
                 intent.getStringExtra(Browser.EXTRA_APPLICATION_ID);
         if (applicationId == null) {
             needsNewTab = (flags & LOADURL_NEW_TAB) != 0;
         } else {
             // If you modify this code, be careful that intent != null.
             final boolean extraCreateNewTab = intent.getBooleanExtra(Browser.EXTRA_CREATE_NEW_TAB, false);
             final Tab applicationTab = getTabForApplicationId(applicationId);