Bug 702778 - Only update the doorhanger popup for the currently selected tab. r=mfinkle

This commit is contained in:
Margaret Leibovic 2011-11-15 14:51:57 -08:00
parent c74dd0c655
commit 21b45c57ac
3 changed files with 17 additions and 20 deletions

View File

@ -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() {

View File

@ -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<String, DoorHanger> 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();

View File

@ -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();
}
}
});