Merge pull request #2969 from yurydelendik/notificationBox

Fixes notificationBox on Linux
This commit is contained in:
Brendan Dahl 2013-03-19 10:23:59 -07:00
commit aa2b1f0a24

View File

@ -386,21 +386,19 @@ ChromeActions.prototype = {
var message = getLocalizedString(strings, 'unsupported_feature'); var message = getLocalizedString(strings, 'unsupported_feature');
var notificationBox = null; var notificationBox = null;
// Multiple browser windows can be opened, finding one for notification box try {
var windowsEnum = Services.wm // Based on MDN's "Working with windows in chrome code"
.getZOrderDOMWindowEnumerator('navigator:browser', true); var mainWindow = domWindow
while (windowsEnum.hasMoreElements()) { .QueryInterface(Components.interfaces.nsIInterfaceRequestor)
var win = windowsEnum.getNext(); .getInterface(Components.interfaces.nsIWebNavigation)
if (win.closed) .QueryInterface(Components.interfaces.nsIDocShellTreeItem)
continue; .rootTreeItem
var browser = win.gBrowser.getBrowserForDocument(domWindow.top.document); .QueryInterface(Components.interfaces.nsIInterfaceRequestor)
if (browser) { .getInterface(Components.interfaces.nsIDOMWindow);
// right window/browser is found, getting the notification box var browser = mainWindow.gBrowser
notificationBox = win.gBrowser.getNotificationBox(browser); .getBrowserForDocument(domWindow.top.document);
break; notificationBox = mainWindow.gBrowser.getNotificationBox(browser);
} } catch (e) {
}
if (!notificationBox) {
log('Unable to get a notification box for the fallback message'); log('Unable to get a notification box for the fallback message');
return; return;
} }