[tor-commits] [tor-browser/tor-browser-60.2.1esr-8.5-1] Bug 1448305 - Avoid disk cache for icons of private tab's session history. r=JanH

gk at torproject.org gk at torproject.org
Thu Oct 18 18:48:43 UTC 2018


commit c72b56ea4eb7dcbb73d1fce9b9ac066abbe5bd53
Author: Rob Wu <rob at robwu.nl>
Date:   Thu Jun 21 15:36:05 2018 +0200

    Bug 1448305 - Avoid disk cache for icons of private tab's session history. r=JanH
---
 mobile/android/base/java/org/mozilla/gecko/BrowserApp.java  |  4 ++--
 .../java/org/mozilla/gecko/tabs/TabHistoryController.java   |  6 ++++--
 .../java/org/mozilla/gecko/tabs/TabHistoryFragment.java     | 13 +++++++++----
 .../base/java/org/mozilla/gecko/tabs/TabHistoryItemRow.java |  3 ++-
 4 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java b/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
index ea9480d149cc..4a497f6999e0 100644
--- a/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
@@ -784,7 +784,7 @@ public class BrowserApp extends GeckoApp
         // Initialize Tab History Controller.
         tabHistoryController = new TabHistoryController(new OnShowTabHistory() {
             @Override
-            public void onShowHistory(final List<TabHistoryPage> historyPageList, final int toIndex) {
+            public void onShowHistory(final List<TabHistoryPage> historyPageList, final int toIndex, final boolean isPrivate) {
                 runOnUiThread(new Runnable() {
                     @Override
                     public void run() {
@@ -798,7 +798,7 @@ public class BrowserApp extends GeckoApp
                             return;
                         }
 
-                        final TabHistoryFragment fragment = TabHistoryFragment.newInstance(historyPageList, toIndex);
+                        final TabHistoryFragment fragment = TabHistoryFragment.newInstance(historyPageList, toIndex, isPrivate);
                         final FragmentManager fragmentManager = getSupportFragmentManager();
                         GeckoAppShell.getHapticFeedbackDelegate().performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
                         fragment.show(R.id.tab_history_panel, fragmentManager.beginTransaction(), TAB_HISTORY_FRAGMENT_TAG);
diff --git a/mobile/android/base/java/org/mozilla/gecko/tabs/TabHistoryController.java b/mobile/android/base/java/org/mozilla/gecko/tabs/TabHistoryController.java
index 0d81f587ca5a..5144c10da05b 100644
--- a/mobile/android/base/java/org/mozilla/gecko/tabs/TabHistoryController.java
+++ b/mobile/android/base/java/org/mozilla/gecko/tabs/TabHistoryController.java
@@ -25,7 +25,7 @@ public class TabHistoryController {
     };
 
     public interface OnShowTabHistory {
-        void onShowHistory(List<TabHistoryPage> historyPageList, int toIndex);
+        void onShowHistory(List<TabHistoryPage> historyPageList, int toIndex, boolean isPrivate);
     }
 
     public TabHistoryController(OnShowTabHistory showTabHistoryListener) {
@@ -40,6 +40,8 @@ public class TabHistoryController {
         data.putString("action", action.name());
         data.putInt("tabId", tab.getId());
 
+        final boolean isPrivate = tab.isPrivate();
+
         EventDispatcher.getInstance().dispatch("Session:GetHistory", data, new EventCallback() {
             @Override
             public void sendSuccess(final Object response) {
@@ -74,7 +76,7 @@ public class TabHistoryController {
                     historyPageList.add(new TabHistoryPage(title, url, selected));
                 }
 
-                showTabHistoryListener.onShowHistory(historyPageList, toIndex);
+                showTabHistoryListener.onShowHistory(historyPageList, toIndex, isPrivate);
             }
 
             @Override
diff --git a/mobile/android/base/java/org/mozilla/gecko/tabs/TabHistoryFragment.java b/mobile/android/base/java/org/mozilla/gecko/tabs/TabHistoryFragment.java
index 3324636e1141..0877fe258746 100644
--- a/mobile/android/base/java/org/mozilla/gecko/tabs/TabHistoryFragment.java
+++ b/mobile/android/base/java/org/mozilla/gecko/tabs/TabHistoryFragment.java
@@ -32,6 +32,7 @@ import android.widget.ListView;
 public class TabHistoryFragment extends Fragment implements OnItemClickListener, OnClickListener {
     private static final String ARG_LIST = "historyPageList";
     private static final String ARG_INDEX = "index";
+    private static final String ARG_PRIVATE_MODE = "private";
     private static final String BACK_STACK_ID = "backStateId";
 
     private List<TabHistoryPage> historyPageList;
@@ -45,11 +46,12 @@ public class TabHistoryFragment extends Fragment implements OnItemClickListener,
 
     }
 
-    public static TabHistoryFragment newInstance(List<TabHistoryPage> historyPageList, int toIndex) {
+    public static TabHistoryFragment newInstance(List<TabHistoryPage> historyPageList, int toIndex, boolean isPrivate) {
         final TabHistoryFragment fragment = new TabHistoryFragment();
         final Bundle args = new Bundle();
         args.putParcelableArrayList(ARG_LIST, (ArrayList<? extends Parcelable>) historyPageList);
         args.putInt(ARG_INDEX, toIndex);
+        args.putBoolean(ARG_PRIVATE_MODE, isPrivate);
         fragment.setArguments(args);
         return fragment;
     }
@@ -79,7 +81,8 @@ public class TabHistoryFragment extends Fragment implements OnItemClickListener,
         Bundle bundle = getArguments();
         historyPageList = bundle.getParcelableArrayList(ARG_LIST);
         toIndex = bundle.getInt(ARG_INDEX);
-        final ArrayAdapter<TabHistoryPage> urlAdapter = new TabHistoryAdapter(getActivity(), historyPageList);
+        boolean isPrivate = bundle.getBoolean(ARG_PRIVATE_MODE);
+        final ArrayAdapter<TabHistoryPage> urlAdapter = new TabHistoryAdapter(getActivity(), historyPageList, isPrivate);
         dialogList.setAdapter(urlAdapter);
         dialogList.setOnItemClickListener(this);
     }
@@ -153,11 +156,13 @@ public class TabHistoryFragment extends Fragment implements OnItemClickListener,
     private static class TabHistoryAdapter extends ArrayAdapter<TabHistoryPage> {
         private final List<TabHistoryPage> pages;
         private final Context context;
+        private final boolean isPrivate;
 
-        public TabHistoryAdapter(Context context, List<TabHistoryPage> pages) {
+        public TabHistoryAdapter(Context context, List<TabHistoryPage> pages, boolean isPrivate) {
             super(context, R.layout.tab_history_item_row, pages);
             this.context = context;
             this.pages = pages;
+            this.isPrivate = isPrivate;
         }
 
         @Override
@@ -167,7 +172,7 @@ public class TabHistoryFragment extends Fragment implements OnItemClickListener,
                 row = new TabHistoryItemRow(context, null);
             }
 
-            row.update(pages.get(position), position == 0, position == pages.size() - 1);
+            row.update(pages.get(position), position == 0, position == pages.size() - 1, isPrivate);
             return row;
         }
     }
diff --git a/mobile/android/base/java/org/mozilla/gecko/tabs/TabHistoryItemRow.java b/mobile/android/base/java/org/mozilla/gecko/tabs/TabHistoryItemRow.java
index 112dbc07dc9a..7e4220c94fd4 100644
--- a/mobile/android/base/java/org/mozilla/gecko/tabs/TabHistoryItemRow.java
+++ b/mobile/android/base/java/org/mozilla/gecko/tabs/TabHistoryItemRow.java
@@ -38,7 +38,7 @@ public class TabHistoryItemRow extends RelativeLayout {
     }
 
     // Update the views with historic page detail.
-    public void update(final TabHistoryPage historyPage, boolean isFirstElement, boolean isLastElement) {
+    public void update(final TabHistoryPage historyPage, boolean isFirstElement, boolean isLastElement, boolean isPrivate) {
         ThreadUtils.assertOnUiThread();
 
         timeLineTop.setVisibility(isFirstElement ? View.INVISIBLE : View.VISIBLE);
@@ -62,6 +62,7 @@ public class TabHistoryItemRow extends RelativeLayout {
 
         ongoingIconLoad = Icons.with(getContext())
                 .pageUrl(historyPage.getUrl())
+                .setPrivateMode(isPrivate)
                 .skipNetwork()
                 .build()
                 .execute(favicon.createIconCallback());





More information about the tor-commits mailing list