Backout js changes from bug 595253 and bug 596776, they were not supposed to land yet. a=backout.

This commit is contained in:
Ben Turner 2010-10-19 12:13:46 -07:00
parent 334f7c09ff
commit e4e99c7f83

View File

@ -5774,7 +5774,6 @@ var IndexedDBPromptHelper = {
_quotaPrompt: "indexedDB-quota-prompt",
_quotaResponse: "indexedDB-quota-response",
_quotaCancel: "indexedDB-quota-cancel",
_notificationIcon: "indexedDB-notification-icon",
@ -5782,21 +5781,18 @@ var IndexedDBPromptHelper = {
function IndexedDBPromptHelper_init() {
Services.obs.addObserver(this, this._permissionsPrompt, false);
Services.obs.addObserver(this, this._quotaPrompt, false);
Services.obs.addObserver(this, this._quotaCancel, false);
},
uninit:
function IndexedDBPromptHelper_uninit() {
Services.obs.removeObserver(this, this._permissionsPrompt, false);
Services.obs.removeObserver(this, this._quotaPrompt, false);
Services.obs.removeObserver(this, this._quotaCancel, false);
},
observe:
function IndexedDBPromptHelper_observe(subject, topic, data) {
if (topic != this._permissionsPrompt &&
topic != this._quotaPrompt &&
topic != this._quotaCancel) {
topic != this._quotaPrompt) {
throw new Error("Unexpected topic!");
}
@ -5828,29 +5824,14 @@ var IndexedDBPromptHelper = {
[ host, data ]);
responseTopic = this._quotaResponse;
}
else if (topic == this._quotaCancel) {
responseTopic = this._quotaResponse;
}
const hiddenTimeoutDuration = 30000; // 30 seconds
const firstTimeoutDuration = 120000; // 2 minutes
var timeoutId;
function cleanup() {
if (timeoutId) {
clearTimeout(timeoutId);
delete timeoutId;
}
}
var self = this;
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);
}
@ -5861,71 +5842,15 @@ var IndexedDBPromptHelper = {
label: gNavigatorBundle.getString("offlineApps.never"),
accessKey: gNavigatorBundle.getString("offlineApps.neverAccessKey"),
callback: function() {
cleanup();
observer.observe(null, responseTopic,
Ci.nsIPermissionManager.DENY_ACTION);
}
}
];
// This will be set to the result of PopupNotifications.show() below, or to
// the result of PopupNotifications.getNotification() if this is a
// quotaCancel notification.
var notification;
PopupNotifications.show(browser, topic, message, this._notificationIcon,
mainAction, secondaryActions);
function timeoutNotification() {
// Remove the notification.
if (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);
}
}
};
if (topic == this._quotaCancel) {
notification = PopupNotifications.getNotification(this._quotaPrompt,
browser);
timeoutNotification();
return;
}
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);
}
};