Bug 702386 - Support setting persistence to -1 for doorhangers (and fix buggy doorhanger removal code). r=mfinkle

This commit is contained in:
Margaret Leibovic 2011-11-15 12:30:54 -08:00
parent 2b2c9c3c76
commit 27eece2b4f
4 changed files with 15 additions and 9 deletions

View File

@ -146,7 +146,9 @@ public class DoorHanger extends LinearLayout implements Button.OnClickListener {
// This method checks with persistence and timeout options to see if
// it's okay to remove a doorhanger.
public boolean shouldRemove() {
if (mPersistence > 0) {
// If persistence is set to -1, the doorhanger will never be
// automatically removed.
if (mPersistence != 0) {
mPersistence--;
return false;
}

View File

@ -575,7 +575,7 @@ abstract public class GeckoApp
tab.updateFavicon(null);
tab.updateFaviconURL(null);
tab.updateSecurityMode("unknown");
tab.removeAllDoorHangers();
tab.removeTransientDoorHangers();
mMainHandler.post(new Runnable() {
public void run() {

View File

@ -245,16 +245,19 @@ public class Tab {
}
public void removeDoorHanger(String value) {
DoorHanger dh = mDoorHangers.get(value);
// Check to see if we should remove a doorhanger before removing it
if (dh.shouldRemove())
mDoorHangers.remove(value);
mDoorHangers.remove(value);
}
public void removeAllDoorHangers() {
mDoorHangers = new HashMap<String, DoorHanger>();
}
public void removeTransientDoorHangers() {
for (String value : mDoorHangers.keySet()) {
removeDoorHanger(value);
}
DoorHanger dh = mDoorHangers.get(value);
if (dh.shouldRemove())
mDoorHangers.remove(value);
}
}
public DoorHanger getDoorHanger(String value) {

View File

@ -667,7 +667,8 @@ var NativeWindow = {
* An options JavaScript object holding additional properties for the
* notification. The following properties are currently supported:
* persistence: An integer. The notification will not automatically
* dismiss for this many page loads.
* dismiss for this many page loads. If persistence is set
* to -1, the doorhanger will never automatically dismiss.
* timeout: A time in milliseconds. The notification will not
* automatically dismiss before this time.
*/