michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: /* vim: set ft=javascript : */ michael@0: michael@0: "use strict"; michael@0: michael@0: let Cu = Components.utils; michael@0: let Ci = Components.interfaces; michael@0: let Cc = Components.classes; michael@0: let Cr = Components.results; michael@0: let Cm = Components.manager.QueryInterface(Ci.nsIComponentRegistrar); michael@0: michael@0: this.EXPORTED_SYMBOLS = ["BrowserElementPromptService"]; michael@0: michael@0: Cu.import("resource://gre/modules/XPCOMUtils.jsm"); michael@0: Cu.import("resource://gre/modules/Services.jsm"); michael@0: michael@0: const NS_PREFBRANCH_PREFCHANGE_TOPIC_ID = "nsPref:changed"; michael@0: const BROWSER_FRAMES_ENABLED_PREF = "dom.mozBrowserFramesEnabled"; michael@0: michael@0: function debug(msg) { michael@0: //dump("BrowserElementPromptService - " + msg + "\n"); michael@0: } michael@0: michael@0: function BrowserElementPrompt(win, browserElementChild) { michael@0: this._win = win; michael@0: this._browserElementChild = browserElementChild; michael@0: } michael@0: michael@0: BrowserElementPrompt.prototype = { michael@0: QueryInterface: XPCOMUtils.generateQI([Ci.nsIPrompt]), michael@0: michael@0: alert: function(title, text) { michael@0: this._browserElementChild.showModalPrompt( michael@0: this._win, {promptType: "alert", title: title, message: text, returnValue: undefined}); michael@0: }, michael@0: michael@0: alertCheck: function(title, text, checkMsg, checkState) { michael@0: // Treat this like a normal alert() call, ignoring the checkState. The michael@0: // front-end can do its own suppression of the alert() if it wants. michael@0: this.alert(title, text); michael@0: }, michael@0: michael@0: confirm: function(title, text) { michael@0: return this._browserElementChild.showModalPrompt( michael@0: this._win, {promptType: "confirm", title: title, message: text, returnValue: undefined}); michael@0: }, michael@0: michael@0: confirmCheck: function(title, text, checkMsg, checkState) { michael@0: return this.confirm(title, text); michael@0: }, michael@0: michael@0: // Each button is described by an object with the following schema michael@0: // { michael@0: // string messageType, // 'builtin' or 'custom' michael@0: // string message, // 'ok', 'cancel', 'yes', 'no', 'save', 'dontsave', michael@0: // // 'revert' or a string from caller if messageType was 'custom'. michael@0: // } michael@0: // michael@0: // Expected result from embedder: michael@0: // { michael@0: // int button, // Index of the button that user pressed. michael@0: // boolean checked, // True if the check box is checked. michael@0: // } michael@0: confirmEx: function(title, text, buttonFlags, button0Title, button1Title, michael@0: button2Title, checkMsg, checkState) { michael@0: let buttonProperties = this._buildConfirmExButtonProperties(buttonFlags, michael@0: button0Title, michael@0: button1Title, michael@0: button2Title); michael@0: let defaultReturnValue = { selectedButton: buttonProperties.defaultButton }; michael@0: if (checkMsg) { michael@0: defaultReturnValue.checked = checkState.value; michael@0: } michael@0: let ret = this._browserElementChild.showModalPrompt( michael@0: this._win, michael@0: { michael@0: promptType: "custom-prompt", michael@0: title: title, michael@0: message: text, michael@0: defaultButton: buttonProperties.defaultButton, michael@0: buttons: buttonProperties.buttons, michael@0: showCheckbox: !!checkMsg, michael@0: checkboxMessage: checkMsg, michael@0: checkboxCheckedByDefault: !!checkState.value, michael@0: returnValue: defaultReturnValue michael@0: } michael@0: ); michael@0: if (checkMsg) { michael@0: checkState.value = ret.checked; michael@0: } michael@0: return buttonProperties.indexToButtonNumberMap[ret.selectedButton]; michael@0: }, michael@0: michael@0: prompt: function(title, text, value, checkMsg, checkState) { michael@0: let rv = this._browserElementChild.showModalPrompt( michael@0: this._win, michael@0: { promptType: "prompt", michael@0: title: title, michael@0: message: text, michael@0: initialValue: value.value, michael@0: returnValue: null }); michael@0: michael@0: value.value = rv; michael@0: michael@0: // nsIPrompt::Prompt returns true if the user pressed "OK" at the prompt, michael@0: // and false if the user pressed "Cancel". michael@0: // michael@0: // BrowserElementChild returns null for "Cancel" and returns the string the michael@0: // user entered otherwise. michael@0: return rv !== null; michael@0: }, michael@0: michael@0: promptUsernameAndPassword: function(title, text, username, password, checkMsg, checkState) { michael@0: throw Cr.NS_ERROR_NOT_IMPLEMENTED; michael@0: }, michael@0: michael@0: promptPassword: function(title, text, password, checkMsg, checkState) { michael@0: throw Cr.NS_ERROR_NOT_IMPLEMENTED; michael@0: }, michael@0: michael@0: select: function(title, text, aCount, aSelectList, aOutSelection) { michael@0: throw Cr.NS_ERROR_NOT_IMPLEMENTED; michael@0: }, michael@0: michael@0: _buildConfirmExButtonProperties: function(buttonFlags, button0Title, michael@0: button1Title, button2Title) { michael@0: let r = { michael@0: defaultButton: -1, michael@0: buttons: [], michael@0: // This map is for translating array index to the button number that michael@0: // is recognized by Gecko. This shouldn't be exposed to embedder. michael@0: indexToButtonNumberMap: [] michael@0: }; michael@0: michael@0: let defaultButton = 0; // Default to Button 0. michael@0: if (buttonFlags & Ci.nsIPrompt.BUTTON_POS_1_DEFAULT) { michael@0: defaultButton = 1; michael@0: } else if (buttonFlags & Ci.nsIPrompt.BUTTON_POS_2_DEFAULT) { michael@0: defaultButton = 2; michael@0: } michael@0: michael@0: // Properties of each button. michael@0: let buttonPositions = [ michael@0: Ci.nsIPrompt.BUTTON_POS_0, michael@0: Ci.nsIPrompt.BUTTON_POS_1, michael@0: Ci.nsIPrompt.BUTTON_POS_2 michael@0: ]; michael@0: michael@0: function buildButton(buttonTitle, buttonNumber) { michael@0: let ret = {}; michael@0: let buttonPosition = buttonPositions[buttonNumber]; michael@0: let mask = 0xff * buttonPosition; // 8 bit mask michael@0: let titleType = (buttonFlags & mask) / buttonPosition; michael@0: michael@0: ret.messageType = 'builtin'; michael@0: switch(titleType) { michael@0: case Ci.nsIPrompt.BUTTON_TITLE_OK: michael@0: ret.message = 'ok'; michael@0: break; michael@0: case Ci.nsIPrompt.BUTTON_TITLE_CANCEL: michael@0: ret.message = 'cancel'; michael@0: break; michael@0: case Ci.nsIPrompt.BUTTON_TITLE_YES: michael@0: ret.message = 'yes'; michael@0: break; michael@0: case Ci.nsIPrompt.BUTTON_TITLE_NO: michael@0: ret.message = 'no'; michael@0: break; michael@0: case Ci.nsIPrompt.BUTTON_TITLE_SAVE: michael@0: ret.message = 'save'; michael@0: break; michael@0: case Ci.nsIPrompt.BUTTON_TITLE_DONT_SAVE: michael@0: ret.message = 'dontsave'; michael@0: break; michael@0: case Ci.nsIPrompt.BUTTON_TITLE_REVERT: michael@0: ret.message = 'revert'; michael@0: break; michael@0: case Ci.nsIPrompt.BUTTON_TITLE_IS_STRING: michael@0: ret.message = buttonTitle; michael@0: ret.messageType = 'custom'; michael@0: break; michael@0: default: michael@0: // This button is not shown. michael@0: return; michael@0: } michael@0: michael@0: // If this is the default button, set r.defaultButton to michael@0: // the index of this button in the array. This value is going to be michael@0: // exposed to the embedder. michael@0: if (defaultButton === buttonNumber) { michael@0: r.defaultButton = r.buttons.length; michael@0: } michael@0: r.buttons.push(ret); michael@0: r.indexToButtonNumberMap.push(buttonNumber); michael@0: } michael@0: michael@0: buildButton(button0Title, 0); michael@0: buildButton(button1Title, 1); michael@0: buildButton(button2Title, 2); michael@0: michael@0: // If defaultButton is still -1 here, it means the default button won't michael@0: // be shown. michael@0: if (r.defaultButton === -1) { michael@0: throw new Components.Exception("Default button won't be shown", michael@0: Cr.NS_ERROR_FAILURE); michael@0: } michael@0: michael@0: return r; michael@0: }, michael@0: }; michael@0: michael@0: michael@0: function BrowserElementAuthPrompt() { michael@0: } michael@0: michael@0: BrowserElementAuthPrompt.prototype = { michael@0: QueryInterface: XPCOMUtils.generateQI([Ci.nsIAuthPrompt2]), michael@0: michael@0: promptAuth: function promptAuth(channel, level, authInfo) { michael@0: throw Cr.NS_ERROR_NOT_IMPLEMENTED; michael@0: }, michael@0: michael@0: asyncPromptAuth: function asyncPromptAuth(channel, callback, context, level, authInfo) { michael@0: debug("asyncPromptAuth"); michael@0: michael@0: // The cases that we don't support now. michael@0: if ((authInfo.flags & Ci.nsIAuthInformation.AUTH_PROXY) && michael@0: (authInfo.flags & Ci.nsIAuthInformation.ONLY_PASSWORD)) { michael@0: throw Cr.NS_ERROR_FAILURE; michael@0: } michael@0: michael@0: let frame = this._getFrameFromChannel(channel); michael@0: if (!frame) { michael@0: debug("Cannot get frame, asyncPromptAuth fail"); michael@0: throw Cr.NS_ERROR_FAILURE; michael@0: } michael@0: michael@0: let browserElementParent = michael@0: BrowserElementPromptService.getBrowserElementParentForFrame(frame); michael@0: michael@0: if (!browserElementParent) { michael@0: debug("Failed to load browser element parent."); michael@0: throw Cr.NS_ERROR_FAILURE; michael@0: } michael@0: michael@0: let consumer = { michael@0: QueryInterface: XPCOMUtils.generateQI([Ci.nsICancelable]), michael@0: callback: callback, michael@0: context: context, michael@0: cancel: function() { michael@0: this.callback.onAuthCancelled(this.context, false); michael@0: this.callback = null; michael@0: this.context = null; michael@0: } michael@0: }; michael@0: michael@0: let [hostname, httpRealm] = this._getAuthTarget(channel, authInfo); michael@0: let hashKey = level + "|" + hostname + "|" + httpRealm; michael@0: let asyncPrompt = this._asyncPrompts[hashKey]; michael@0: if (asyncPrompt) { michael@0: asyncPrompt.consumers.push(consumer); michael@0: return consumer; michael@0: } michael@0: michael@0: asyncPrompt = { michael@0: consumers: [consumer], michael@0: channel: channel, michael@0: authInfo: authInfo, michael@0: level: level, michael@0: inProgress: false, michael@0: browserElementParent: browserElementParent michael@0: }; michael@0: michael@0: this._asyncPrompts[hashKey] = asyncPrompt; michael@0: this._doAsyncPrompt(); michael@0: return consumer; michael@0: }, michael@0: michael@0: // Utilities for nsIAuthPrompt2 ---------------- michael@0: michael@0: _asyncPrompts: {}, michael@0: _asyncPromptInProgress: new WeakMap(), michael@0: _doAsyncPrompt: function() { michael@0: // Find the key of a prompt whose browser element parent does not have michael@0: // async prompt in progress. michael@0: let hashKey = null; michael@0: for (let key in this._asyncPrompts) { michael@0: let prompt = this._asyncPrompts[key]; michael@0: if (!this._asyncPromptInProgress.get(prompt.browserElementParent)) { michael@0: hashKey = key; michael@0: break; michael@0: } michael@0: } michael@0: michael@0: // Didn't find an available prompt, so just return. michael@0: if (!hashKey) michael@0: return; michael@0: michael@0: let prompt = this._asyncPrompts[hashKey]; michael@0: let [hostname, httpRealm] = this._getAuthTarget(prompt.channel, michael@0: prompt.authInfo); michael@0: michael@0: this._asyncPromptInProgress.set(prompt.browserElementParent, true); michael@0: prompt.inProgress = true; michael@0: michael@0: let self = this; michael@0: let callback = function(ok, username, password) { michael@0: debug("Async auth callback is called, ok = " + michael@0: ok + ", username = " + username); michael@0: michael@0: // Here we got the username and password provided by embedder, or michael@0: // ok = false if the prompt was cancelled by embedder. michael@0: delete self._asyncPrompts[hashKey]; michael@0: prompt.inProgress = false; michael@0: self._asyncPromptInProgress.delete(prompt.browserElementParent); michael@0: michael@0: // Fill authentication information with username and password provided michael@0: // by user. michael@0: let flags = prompt.authInfo.flags; michael@0: if (username) { michael@0: if (flags & Ci.nsIAuthInformation.NEED_DOMAIN) { michael@0: // Domain is separated from username by a backslash michael@0: let idx = username.indexOf("\\"); michael@0: if (idx == -1) { michael@0: prompt.authInfo.username = username; michael@0: } else { michael@0: prompt.authInfo.domain = username.substring(0, idx); michael@0: prompt.authInfo.username = username.substring(idx + 1); michael@0: } michael@0: } else { michael@0: prompt.authInfo.username = username; michael@0: } michael@0: } michael@0: michael@0: if (password) { michael@0: prompt.authInfo.password = password; michael@0: } michael@0: michael@0: for each (let consumer in prompt.consumers) { michael@0: if (!consumer.callback) { michael@0: // Not having a callback means that consumer didn't provide it michael@0: // or canceled the notification. michael@0: continue; michael@0: } michael@0: michael@0: try { michael@0: if (ok) { michael@0: debug("Ok, calling onAuthAvailable to finish auth"); michael@0: consumer.callback.onAuthAvailable(consumer.context, prompt.authInfo); michael@0: } else { michael@0: debug("Cancelled, calling onAuthCancelled to finish auth."); michael@0: consumer.callback.onAuthCancelled(consumer.context, true); michael@0: } michael@0: } catch (e) { /* Throw away exceptions caused by callback */ } michael@0: } michael@0: michael@0: // Process the next prompt, if one is pending. michael@0: self._doAsyncPrompt(); michael@0: }; michael@0: michael@0: let runnable = { michael@0: run: function() { michael@0: // Call promptAuth of browserElementParent, to show the prompt. michael@0: prompt.browserElementParent.promptAuth( michael@0: self._createAuthDetail(prompt.channel, prompt.authInfo), michael@0: callback); michael@0: } michael@0: } michael@0: michael@0: Services.tm.currentThread.dispatch(runnable, Ci.nsIThread.DISPATCH_NORMAL); michael@0: }, michael@0: michael@0: _getFrameFromChannel: function(channel) { michael@0: let loadContext = channel.notificationCallbacks.getInterface(Ci.nsILoadContext); michael@0: return loadContext.topFrameElement; michael@0: }, michael@0: michael@0: _createAuthDetail: function(channel, authInfo) { michael@0: let [hostname, httpRealm] = this._getAuthTarget(channel, authInfo); michael@0: return { michael@0: host: hostname, michael@0: realm: httpRealm, michael@0: username: authInfo.username, michael@0: isOnlyPassword: !!(authInfo.flags & Ci.nsIAuthInformation.ONLY_PASSWORD) michael@0: }; michael@0: }, michael@0: michael@0: _getAuthTarget : function (channel, authInfo) { michael@0: let hostname = this._getFormattedHostname(channel.URI); michael@0: michael@0: // If a HTTP WWW-Authenticate header specified a realm, that value michael@0: // will be available here. If it wasn't set or wasn't HTTP, we'll use michael@0: // the formatted hostname instead. michael@0: let realm = authInfo.realm; michael@0: if (!realm) michael@0: realm = hostname; michael@0: michael@0: return [hostname, realm]; michael@0: }, michael@0: michael@0: _getFormattedHostname : function(uri) { michael@0: let scheme = uri.scheme; michael@0: let hostname = scheme + "://" + uri.host; michael@0: michael@0: // If the URI explicitly specified a port, only include it when michael@0: // it's not the default. (We never want "http://foo.com:80") michael@0: let port = uri.port; michael@0: if (port != -1) { michael@0: let handler = Services.io.getProtocolHandler(scheme); michael@0: if (port != handler.defaultPort) michael@0: hostname += ":" + port; michael@0: } michael@0: return hostname; michael@0: } michael@0: }; michael@0: michael@0: michael@0: function AuthPromptWrapper(oldImpl, browserElementImpl) { michael@0: this._oldImpl = oldImpl; michael@0: this._browserElementImpl = browserElementImpl; michael@0: } michael@0: michael@0: AuthPromptWrapper.prototype = { michael@0: QueryInterface: XPCOMUtils.generateQI([Ci.nsIAuthPrompt2]), michael@0: promptAuth: function(channel, level, authInfo) { michael@0: if (this._canGetParentElement(channel)) { michael@0: return this._browserElementImpl.promptAuth(channel, level, authInfo); michael@0: } else { michael@0: return this._oldImpl.promptAuth(channel, level, authInfo); michael@0: } michael@0: }, michael@0: michael@0: asyncPromptAuth: function(channel, callback, context, level, authInfo) { michael@0: if (this._canGetParentElement(channel)) { michael@0: return this._browserElementImpl.asyncPromptAuth(channel, callback, context, level, authInfo); michael@0: } else { michael@0: return this._oldImpl.asyncPromptAuth(channel, callback, context, level, authInfo); michael@0: } michael@0: }, michael@0: michael@0: _canGetParentElement: function(channel) { michael@0: try { michael@0: let frame = channel.notificationCallbacks.getInterface(Ci.nsILoadContext).topFrameElement; michael@0: if (!frame) michael@0: return false; michael@0: michael@0: if (!BrowserElementPromptService.getBrowserElementParentForFrame(frame)) michael@0: return false; michael@0: michael@0: return true; michael@0: } catch (e) { michael@0: return false; michael@0: } michael@0: } michael@0: }; michael@0: michael@0: function BrowserElementPromptFactory(toWrap) { michael@0: this._wrapped = toWrap; michael@0: } michael@0: michael@0: BrowserElementPromptFactory.prototype = { michael@0: classID: Components.ID("{24f3d0cf-e417-4b85-9017-c9ecf8bb1299}"), michael@0: QueryInterface: XPCOMUtils.generateQI([Ci.nsIPromptFactory]), michael@0: michael@0: _mayUseNativePrompt: function() { michael@0: try { michael@0: return Services.prefs.getBoolPref("browser.prompt.allowNative"); michael@0: } catch (e) { michael@0: // This properity is default to true. michael@0: return true; michael@0: } michael@0: }, michael@0: michael@0: _getNativePromptIfAllowed: function(win, iid, err) { michael@0: if (this._mayUseNativePrompt()) michael@0: return this._wrapped.getPrompt(win, iid); michael@0: else { michael@0: // Not allowed, throw an exception. michael@0: throw err; michael@0: } michael@0: }, michael@0: michael@0: getPrompt: function(win, iid) { michael@0: // It is possible for some object to get a prompt without passing michael@0: // valid reference of window, like nsNSSComponent. In such case, we michael@0: // should just fall back to the native prompt service michael@0: if (!win) michael@0: return this._getNativePromptIfAllowed(win, iid, Cr.NS_ERROR_INVALID_ARG); michael@0: michael@0: if (iid.number != Ci.nsIPrompt.number && michael@0: iid.number != Ci.nsIAuthPrompt2.number) { michael@0: debug("We don't recognize the requested IID (" + iid + ", " + michael@0: "allowed IID: " + michael@0: "nsIPrompt=" + Ci.nsIPrompt + ", " + michael@0: "nsIAuthPrompt2=" + Ci.nsIAuthPrompt2 + ")"); michael@0: return this._getNativePromptIfAllowed(win, iid, Cr.NS_ERROR_INVALID_ARG); michael@0: } michael@0: michael@0: // Try to find a BrowserElementChild for the window. michael@0: let browserElementChild = michael@0: BrowserElementPromptService.getBrowserElementChildForWindow(win); michael@0: michael@0: if (iid.number === Ci.nsIAuthPrompt2.number) { michael@0: debug("Caller requests an instance of nsIAuthPrompt2."); michael@0: michael@0: if (browserElementChild) { michael@0: // If we are able to get a BrowserElementChild, it means that michael@0: // the auth prompt is for a mozbrowser. Therefore we don't need to michael@0: // fall back. michael@0: return new BrowserElementAuthPrompt().QueryInterface(iid); michael@0: } michael@0: michael@0: // Because nsIAuthPrompt2 is called in parent process. If caller michael@0: // wants nsIAuthPrompt2 and we cannot get BrowserElementchild, michael@0: // it doesn't mean that we should fallback. It is possible that we can michael@0: // get the BrowserElementParent from nsIChannel that passed to michael@0: // functions of nsIAuthPrompt2. michael@0: if (this._mayUseNativePrompt()) { michael@0: return new AuthPromptWrapper( michael@0: this._wrapped.getPrompt(win, iid), michael@0: new BrowserElementAuthPrompt().QueryInterface(iid)) michael@0: .QueryInterface(iid); michael@0: } else { michael@0: // Falling back is not allowed, so we don't need wrap the michael@0: // BrowserElementPrompt. michael@0: return new BrowserElementAuthPrompt().QueryInterface(iid); michael@0: } michael@0: } michael@0: michael@0: if (!browserElementChild) { michael@0: debug("We can't find a browserElementChild for " + michael@0: win + ", " + win.location); michael@0: return this._getNativePromptIfAllowed(win, iid, Cr.NS_ERROR_FAILURE); michael@0: } michael@0: michael@0: debug("Returning wrapped getPrompt for " + win); michael@0: return new BrowserElementPrompt(win, browserElementChild) michael@0: .QueryInterface(iid); michael@0: } michael@0: }; michael@0: michael@0: this.BrowserElementPromptService = { michael@0: QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver, michael@0: Ci.nsISupportsWeakReference]), michael@0: michael@0: _initialized: false, michael@0: michael@0: _init: function() { michael@0: if (this._initialized) { michael@0: return; michael@0: } michael@0: michael@0: // If the pref is disabled, do nothing except wait for the pref to change. michael@0: if (!this._browserFramesPrefEnabled()) { michael@0: var prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch); michael@0: prefs.addObserver(BROWSER_FRAMES_ENABLED_PREF, this, /* ownsWeak = */ true); michael@0: return; michael@0: } michael@0: michael@0: this._initialized = true; michael@0: this._browserElementParentMap = new WeakMap(); michael@0: michael@0: var os = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService); michael@0: os.addObserver(this, "outer-window-destroyed", /* ownsWeak = */ true); michael@0: michael@0: // Wrap the existing @mozilla.org/prompter;1 implementation. michael@0: var contractID = "@mozilla.org/prompter;1"; michael@0: var oldCID = Cm.contractIDToCID(contractID); michael@0: var newCID = BrowserElementPromptFactory.prototype.classID; michael@0: var oldFactory = Cm.getClassObject(Cc[contractID], Ci.nsIFactory); michael@0: michael@0: if (oldCID == newCID) { michael@0: debug("WARNING: Wrapped prompt factory is already installed!"); michael@0: return; michael@0: } michael@0: michael@0: Cm.unregisterFactory(oldCID, oldFactory); michael@0: michael@0: var oldInstance = oldFactory.createInstance(null, Ci.nsIPromptFactory); michael@0: var newInstance = new BrowserElementPromptFactory(oldInstance); michael@0: michael@0: var newFactory = { michael@0: createInstance: function(outer, iid) { michael@0: if (outer != null) { michael@0: throw Cr.NS_ERROR_NO_AGGREGATION; michael@0: } michael@0: return newInstance.QueryInterface(iid); michael@0: } michael@0: }; michael@0: Cm.registerFactory(newCID, michael@0: "BrowserElementPromptService's prompter;1 wrapper", michael@0: contractID, newFactory); michael@0: michael@0: debug("Done installing new prompt factory."); michael@0: }, michael@0: michael@0: _getOuterWindowID: function(win) { michael@0: return win.QueryInterface(Ci.nsIInterfaceRequestor) michael@0: .getInterface(Ci.nsIDOMWindowUtils) michael@0: .outerWindowID; michael@0: }, michael@0: michael@0: _browserElementChildMap: {}, michael@0: mapWindowToBrowserElementChild: function(win, browserElementChild) { michael@0: this._browserElementChildMap[this._getOuterWindowID(win)] = browserElementChild; michael@0: }, michael@0: michael@0: getBrowserElementChildForWindow: function(win) { michael@0: // We only have a mapping for