Bug 1189453 - Update loadUrlInTab to load the URL in the same private context as its parent tab. r=liuche
authorMargaret Leibovic <margaret.leibovic@gmail.com>
Tue, 04 Aug 2015 16:24:43 -0400
changeset 288248 7ca5e33f197246142b5478fbc147af6caa5aa512
parent 288247 80f658adde86a079434d32702cadc281e386f51a
child 288249 551a1a46ac443fa6a716d353fbe87d936e3961ca
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersliuche
bugs1189453
milestone42.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
Bug 1189453 - Update loadUrlInTab to load the URL in the same private context as its parent tab. r=liuche
mobile/android/base/Tabs.java
--- a/mobile/android/base/Tabs.java
+++ b/mobile/android/base/Tabs.java
@@ -960,37 +960,45 @@ public class Tabs implements GeckoEventL
 
     /**
      * Open the url as a new tab, and mark the selected tab as its "parent".
      *
      * If the url is already open in a tab, the existing tab is selected.
      * Use this for tabs opened by the browser chrome, so users can press the
      * "Back" button to return to the previous tab.
      *
+     * This method will open a new private tab if the currently selected tab
+     * is also private.
+     *
      * @param url URL of page to load
      */
     public void loadUrlInTab(String url) {
         Iterable<Tab> tabs = getTabsInOrder();
         for (Tab tab : tabs) {
             if (url.equals(tab.getURL())) {
                 selectTab(tab.getId());
                 return;
             }
         }
 
         // getSelectedTab() can return null if no tab has been created yet
         // (i.e., we're restoring a session after a crash). In these cases,
         // don't mark any tabs as a parent.
         int parentId = -1;
-        Tab selectedTab = getSelectedTab();
+        int flags = LOADURL_NEW_TAB;
+
+        final Tab selectedTab = getSelectedTab();
         if (selectedTab != null) {
             parentId = selectedTab.getId();
+            if (selectedTab.isPrivate()) {
+                flags = flags | LOADURL_PRIVATE;
+            }
         }
 
-        loadUrl(url, null, parentId, LOADURL_NEW_TAB);
+        loadUrl(url, null, parentId, flags);
     }
 
     /**
      * Gets the next tab ID.
      */
     @JNITarget
     public static int getNextTabId() {
         return sTabId.getAndIncrement();