diff --git a/embedding/android/DoorHanger.java b/embedding/android/DoorHanger.java index 1feca3ff8354..2e49a4c0f84f 100644 --- a/embedding/android/DoorHanger.java +++ b/embedding/android/DoorHanger.java @@ -102,7 +102,7 @@ public class DoorHanger extends LinearLayout implements Button.OnClickListener { // This will hide the doorhanger (and hide the popup if there are no // more doorhangers to show) - GeckoApp.mDoorHangerPopup.updatePopupForTab(mTab); + GeckoApp.mDoorHangerPopup.updatePopup(); } public void show() { diff --git a/embedding/android/DoorHangerPopup.java b/embedding/android/DoorHangerPopup.java index 79e0e13021a1..6ff09ec10ec4 100644 --- a/embedding/android/DoorHangerPopup.java +++ b/embedding/android/DoorHangerPopup.java @@ -103,23 +103,14 @@ public class DoorHangerPopup extends PopupWindow { tab.addDoorHanger(value, dh); mContent.addView(dh); - updatePopupForTab(tab); + updatePopup(); } - // Updates popup contents to show doorhangers associated with tab - public void updatePopupForTab(Tab tab) { - if (tab == null) { - hidePopup(); - return; - } - - // Hide old doorhangers - for (int i = 0; i < mContent.getChildCount(); i++) { - DoorHanger dh = (DoorHanger) mContent.getChildAt(i); - dh.hide(); - } - + // Updates popup contents to show doorhangers for the selected tab + public void updatePopup() { + Tab tab = Tabs.getInstance().getSelectedTab(); Log.i("DoorHangerPopup", "Showing all doorhangers for tab: " + tab.getId()); + HashMap doorHangers = tab.getDoorHangers(); // Hide the popup if there aren't any doorhangers to show if (doorHangers == null || doorHangers.size() == 0) { @@ -127,6 +118,12 @@ public class DoorHangerPopup extends PopupWindow { return; } + // Hide old doorhangers + for (int i = 0; i < mContent.getChildCount(); i++) { + DoorHanger dh = (DoorHanger) mContent.getChildAt(i); + dh.hide(); + } + // Show the doorhangers for the tab for (DoorHanger dh : doorHangers.values()) { dh.show(); diff --git a/embedding/android/GeckoApp.java b/embedding/android/GeckoApp.java index 50b441851dc4..6346af821d40 100644 --- a/embedding/android/GeckoApp.java +++ b/embedding/android/GeckoApp.java @@ -583,7 +583,7 @@ abstract public class GeckoApp mBrowserToolbar.setTitle(uri); mBrowserToolbar.setFavicon(null); mBrowserToolbar.setSecurityMode("unknown"); - mDoorHangerPopup.updatePopupForTab(tab); + mDoorHangerPopup.updatePopup(); } } }); @@ -812,7 +812,7 @@ abstract public class GeckoApp if (tab == null) return; tab.removeDoorHanger(value); - mDoorHangerPopup.updatePopupForTab(tab); + mDoorHangerPopup.updatePopup(); } }); } @@ -827,7 +827,7 @@ abstract public class GeckoApp public void run() { if (selected && Tabs.getInstance().isSelectedTab(tab)) { onTabsChanged(); - mDoorHangerPopup.updatePopupForTab(tab); + mDoorHangerPopup.updatePopup(); } mBrowserToolbar.updateTabs(Tabs.getInstance().getCount()); } @@ -843,7 +843,7 @@ abstract public class GeckoApp public void run() { onTabsChanged(); mBrowserToolbar.updateTabs(Tabs.getInstance().getCount()); - mDoorHangerPopup.updatePopupForTab(tab); + mDoorHangerPopup.updatePopup(); } }); } @@ -860,7 +860,7 @@ abstract public class GeckoApp mBrowserToolbar.setFavicon(tab.getFavicon()); mBrowserToolbar.setSecurityMode(tab.getSecurityMode()); mBrowserToolbar.setProgressVisibility(tab.isLoading()); - mDoorHangerPopup.updatePopupForTab(tab); + mDoorHangerPopup.updatePopup(); } } });