зеркало из https://github.com/mozilla/pjs.git
Bug 595253 - 'IndexedDB: Notifications should auto-dismiss in some circumstances'. r=gavin.
This commit is contained in:
Родитель
f287763f50
Коммит
584e56153e
|
@ -5825,13 +5825,25 @@ var IndexedDBPromptHelper = {
|
|||
responseTopic = this._quotaResponse;
|
||||
}
|
||||
|
||||
var self = this;
|
||||
const hiddenTimeoutDuration = 30000; // 30 seconds
|
||||
const firstTimeoutDuration = 120000; // 2 minutes
|
||||
|
||||
var timeoutId;
|
||||
|
||||
function cleanup() {
|
||||
if (timeoutId) {
|
||||
clearTimeout(timeoutId);
|
||||
delete timeoutId;
|
||||
}
|
||||
}
|
||||
|
||||
var observer = requestor.getInterface(Ci.nsIObserver);
|
||||
|
||||
var mainAction = {
|
||||
label: gNavigatorBundle.getString("offlineApps.allow"),
|
||||
accessKey: gNavigatorBundle.getString("offlineApps.allowAccessKey"),
|
||||
callback: function() {
|
||||
cleanup();
|
||||
observer.observe(null, responseTopic,
|
||||
Ci.nsIPermissionManager.ALLOW_ACTION);
|
||||
}
|
||||
|
@ -5842,15 +5854,60 @@ var IndexedDBPromptHelper = {
|
|||
label: gNavigatorBundle.getString("offlineApps.never"),
|
||||
accessKey: gNavigatorBundle.getString("offlineApps.neverAccessKey"),
|
||||
callback: function() {
|
||||
cleanup();
|
||||
observer.observe(null, responseTopic,
|
||||
Ci.nsIPermissionManager.DENY_ACTION);
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
PopupNotifications.show(browser, topic, message, this._notificationIcon,
|
||||
mainAction, secondaryActions);
|
||||
// This will be set to the result of PopupNotifications.show() below.
|
||||
var notification;
|
||||
|
||||
function timeoutNotification() {
|
||||
// Remove the notification.
|
||||
notification.remove();
|
||||
|
||||
// Clear all of our timeout stuff.
|
||||
cleanup();
|
||||
|
||||
// And tell the page that the popup timed out.
|
||||
observer.observe(null, responseTopic,
|
||||
Ci.nsIPermissionManager.UNKNOWN_ACTION);
|
||||
}
|
||||
|
||||
var options = {
|
||||
eventCallback: function(state) {
|
||||
// Don't do anything if the timeout has not been set or if a selection
|
||||
// has already been made (either by user action or by timing out).
|
||||
if (!timeoutId) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If the popup is being dismissed start the short timeout.
|
||||
if (state == "dismissed") {
|
||||
clearTimeout(timeoutId);
|
||||
timeoutId = setTimeout(timeoutNotification, hiddenTimeoutDuration);
|
||||
return;
|
||||
}
|
||||
|
||||
// If the popup is being re-shown then clear the timeout allowing
|
||||
// unlimited waiting. Don't unset timeoutId though or we will fail to
|
||||
// launch the short timeout if the popup is dismissed.
|
||||
else if (state == "shown") {
|
||||
clearTimeout(timeoutId);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
notification = PopupNotifications.show(browser, topic, message,
|
||||
this._notificationIcon, mainAction,
|
||||
secondaryActions, options);
|
||||
|
||||
// Set the timeoutId after the popup has been created, and use the long
|
||||
// timeout value. If the user doesn't notice the popup after this amount of
|
||||
// time then it is most likely not visible and we want to alert the page.
|
||||
timeoutId = setTimeout(timeoutNotification, firstTimeoutDuration);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче