author | Ben Turner <bent.mozilla@gmail.com> |
Tue, 19 Oct 2010 10:58:36 -0700 | |
changeset 56108 | b1d573743e353a8e644474bd4b072f71df893e12 |
parent 56107 | 6476d61a80d5642548f6fa7691d95282d3f99e3d |
child 56109 | 1e456c2f2c8f7b5f6f2fe43fb437c10f80775628 |
push id | 16410 |
push user | bturner@mozilla.com |
push date | Tue, 19 Oct 2010 18:00:11 +0000 |
treeherder | mozilla-central@5fc19997e7bf [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | gavin |
bugs | 595253 |
milestone | 2.0b8pre |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -5820,42 +5820,99 @@ var IndexedDBPromptHelper = { responseTopic = this._permissionsResponse; } else if (topic == this._quotaPrompt) { message = gNavigatorBundle.getFormattedString("indexedDB.usage", [ host, data ]); 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); } }; var secondaryActions = [ { 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); } }; function WindowIsClosing() { if (TabView.isVisible()) { TabView.hide(); return false;