/usr/share/xul-ext/unity/content/unity-window-helper.js is in xul-ext-unity 3.0.0+14.04.20140416-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
var consoleService = Components.classes["@mozilla.org/consoleservice;1"]
.getService(Components.interfaces.nsIConsoleService);
function UnityWindowHelper (aWindow) {
this.window = aWindow;
}
UnityWindowHelper.prototype.FindToplevelContentWindow = function (aWindow) {
var toplevelContentWindow = aWindow;
while (toplevelContentWindow.parent != toplevelContentWindow){
toplevelContentWindow = toplevelContentWindow.parent;
}
return toplevelContentWindow;
}
UnityWindowHelper.prototype.makeCloseCallback = function () {
var window = this.window;
var self = this;
var closeCallback = function(context, userData) {
var mainWindow = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIWebNavigation)
.QueryInterface(Components.interfaces.nsIDocShellTreeItem)
.rootTreeItem
.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIDOMWindow);
var toplevelContentWindow = self.FindToplevelContentWindow(window);
var tab = mainWindow.gBrowser.tabs.item(mainWindow.gBrowser.getBrowserIndexForDocument (toplevelContentWindow.document));
mainWindow.gBrowser.removeTab (tab);
}
return closeCallback;
}
UnityWindowHelper.prototype.makeRaiseCallback = function (unity) {
var window = this.window;
var uwin = XPCNativeWrapper.unwrap(window);
var self = this;
var raiseCallback = function(context, file, userData) {
var toplevelContentWindow = self.FindToplevelContentWindow(window);
var mainWindow = toplevelContentWindow.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIWebNavigation)
.QueryInterface(Components.interfaces.nsIDocShellTreeItem)
.rootTreeItem
.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIDOMWindow);
var chromeWindow = mainWindow.QueryInterface(Components.interfaces.nsIInterfaceRequestor).getInterface(Components.interfaces.nsIDOMChromeWindow);
uwin.focus();
mainWindow.focus();
chromeWindow.getAttention();
var index = mainWindow.gBrowser.getBrowserIndexForDocument (toplevelContentWindow.document);
var tab = mainWindow.gBrowser.tabContainer.childNodes[index];
index = mainWindow.gBrowser.visibleTabs.indexOf(tab);
if (index == -1) {
if (mainWindow.TabView.getContentWindow())
mainWindow.TabView.getContentWindow().UI.goToTab(tab);
} else {
mainWindow.gBrowser.selectTabAtIndex(index);
}
if (!file.isNull()) {
if (unity.acceptDataCallback)
unity.acceptDataCallback(File(file.readString()));
}
};
return raiseCallback;
};
var EXPORTED_SYMBOLS = ["UnityWindowHelper"];
|