Bug 1110069 - Replace getBrowser() with gBrowser. r=dao
--- a/browser/base/content/browser-safebrowsing.js
+++ b/browser/base/content/browser-safebrowsing.js
@@ -2,17 +2,17 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#ifdef MOZ_SAFE_BROWSING
var gSafeBrowsing = {
setReportPhishingMenu: function() {
// A phishing page will have a specific about:blocked content documentURI
- var uri = getBrowser().currentURI;
+ var uri = gBrowser.currentURI;
var isPhishingPage = uri && uri.spec.startsWith("about:blocked?e=phishingBlocked");
// Show/hide the appropriate menu item.
document.getElementById("menu_HelpPopup_reportPhishingtoolmenu")
.hidden = isPhishingPage;
document.getElementById("menu_HelpPopup_reportPhishingErrortoolmenu")
.hidden = !isPhishingPage;
--- a/browser/base/content/urlbarBindings.xml
+++ b/browser/base/content/urlbarBindings.xml
@@ -1053,17 +1053,17 @@
let addEngineList =
document.getAnonymousElementByAttribute(this, "anonid", "add-engines");
while (addEngineList.firstChild)
addEngineList.firstChild.remove();
const kXULNS =
"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
- let addEngines = getBrowser().mCurrentBrowser.engines;
+ let addEngines = gBrowser.mCurrentBrowser.engines;
if (addEngines && addEngines.length > 0) {
const kBundleURI = "chrome://browser/locale/search.properties";
let bundle = Services.strings.createBundle(kBundleURI);
for (let engine of addEngines) {
let button = document.createElementNS(kXULNS, "button");
let label = bundle.formatStringFromName("cmd_addFoundEngine",
[engine.title], 1);
button.setAttribute("class", "addengine-item");
--- a/browser/components/feeds/WebContentConverter.js
+++ b/browser/components/feeds/WebContentConverter.js
@@ -447,17 +447,17 @@ WebContentConverterRegistrar.prototype =
handlerInfo.alwaysAskBeforeHandling = true;
var hs = Cc["@mozilla.org/uriloader/handler-service;1"].
getService(Ci.nsIHandlerService);
hs.store(handlerInfo);
}
};
var browserElement = this._getBrowserForContentWindow(browserWindow, aContentWindow);
- var notificationBox = browserWindow.getBrowser().getNotificationBox(browserElement);
+ var notificationBox = browserWindow.gBrowser.getNotificationBox(browserElement);
notificationBox.appendNotification(message,
notificationValue,
notificationIcon,
notificationBox.PRIORITY_INFO_LOW,
[addButton]);
},
/**
@@ -476,17 +476,17 @@ WebContentConverterRegistrar.prototype =
if (contentType != TYPE_MAYBE_FEED)
return;
if (aContentWindow) {
var uri = this._checkAndGetURI(aURIString, aContentWindow);
var browserWindow = this._getBrowserWindowForContentWindow(aContentWindow);
var browserElement = this._getBrowserForContentWindow(browserWindow, aContentWindow);
- var notificationBox = browserWindow.getBrowser().getNotificationBox(browserElement);
+ var notificationBox = browserWindow.gBrowser.getNotificationBox(browserElement);
this._appendFeedReaderNotification(uri, aTitle, notificationBox);
}
else
this._registerContentHandler(contentType, aURIString, aTitle);
},
/**
* Returns the browser chrome window in which the content window is in
@@ -511,17 +511,17 @@ WebContentConverterRegistrar.prototype =
* @param aContentWindow
* The content window. It's possible to pass a child content window
* (i.e. the content window of a frame/iframe).
*/
_getBrowserForContentWindow:
function WCCR__getBrowserForContentWindow(aBrowserWindow, aContentWindow) {
// This depends on pseudo APIs of browser.js and tabbrowser.xml
aContentWindow = aContentWindow.top;
- var browsers = aBrowserWindow.getBrowser().browsers;
+ var browsers = aBrowserWindow.gBrowser.browsers;
for (var i = 0; i < browsers.length; ++i) {
if (browsers[i].contentWindow == aContentWindow)
return browsers[i];
}
},
/**
* Appends a notifcation for the given feed reader details.
--- a/browser/components/search/content/search.xml
+++ b/browser/components/search/content/search.xml
@@ -344,17 +344,17 @@
// indexes as items are removed.
var items = popup.childNodes;
for (var i = items.length - 1; i >= 0; i--) {
if (items[i].classList.contains("addengine-item") ||
items[i].classList.contains("addengine-separator"))
popup.removeChild(items[i]);
}
- var addengines = getBrowser().mCurrentBrowser.engines;
+ var addengines = gBrowser.mCurrentBrowser.engines;
if (addengines && addengines.length > 0) {
const kXULNS =
"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
// Find the (first) separator in the remaining menu, or the first item
// if no separators are present.
var insertLocation = popup.firstChild;
while (insertLocation.nextSibling &&
--- a/browser/devtools/shared/DeveloperToolbar.jsm
+++ b/browser/devtools/shared/DeveloperToolbar.jsm
@@ -212,17 +212,17 @@ let CommandUtils = {
return this.target.tab.ownerDocument.defaultView;
},
get chromeDocument() {
return this.chromeWindow.document;
},
get window() {
- return this.chromeWindow.getBrowser().selectedTab.linkedBrowser.contentWindow;
+ return this.chromeWindow.gBrowser.selectedTab.linkedBrowser.contentWindow;
},
get document() {
return this.window.document;
}
};
},
};
@@ -291,17 +291,17 @@ const NOTIFICATIONS = {
*/
DeveloperToolbar.prototype.NOTIFICATIONS = NOTIFICATIONS;
/**
* target is dynamic because the selectedTab changes
*/
Object.defineProperty(DeveloperToolbar.prototype, "target", {
get: function() {
- return TargetFactory.forTab(this._chromeWindow.getBrowser().selectedTab);
+ return TargetFactory.forTab(this._chromeWindow.gBrowser.selectedTab);
},
enumerable: true
});
/**
* Is the toolbar open?
*/
Object.defineProperty(DeveloperToolbar.prototype, 'visible', {
@@ -405,17 +405,17 @@ DeveloperToolbar.prototype.show = functi
];
return promise.all(panelPromises).then(panels => {
[ this.tooltipPanel, this.outputPanel ] = panels;
this._doc.getElementById("Tools:DevToolbar").setAttribute("checked", "true");
return gcli.load().then(() => {
this.display = gcli.createDisplay({
- contentDocument: this._chromeWindow.getBrowser().contentDocument,
+ contentDocument: this._chromeWindow.gBrowser.contentDocument,
chromeDocument: this._doc,
chromeWindow: this._chromeWindow,
hintElement: this.tooltipPanel.hintElement,
inputElement: this._input,
completeElement: this._doc.querySelector(".gclitoolbar-complete-node"),
backgroundElement: this._doc.querySelector(".gclitoolbar-stack-node"),
outputDocument: this.outputPanel.document,
environment: CommandUtils.createEnvironment(this, "target"),
@@ -428,17 +428,17 @@ DeveloperToolbar.prototype.show = functi
this.display.focusManager.addMonitoredElement(this._element);
this.display.onVisibilityChange.add(this.outputPanel._visibilityChanged,
this.outputPanel);
this.display.onVisibilityChange.add(this.tooltipPanel._visibilityChanged,
this.tooltipPanel);
this.display.onOutput.add(this.outputPanel._outputChanged, this.outputPanel);
- let tabbrowser = this._chromeWindow.getBrowser();
+ let tabbrowser = this._chromeWindow.gBrowser;
tabbrowser.tabContainer.addEventListener("TabSelect", this, false);
tabbrowser.tabContainer.addEventListener("TabClose", this, false);
tabbrowser.addEventListener("load", this, true);
tabbrowser.addEventListener("beforeunload", this, true);
this._initErrorsCount(tabbrowser.selectedTab);
this._devtoolsUnloaded = this._devtoolsUnloaded.bind(this);
this._devtoolsLoaded = this._devtoolsLoaded.bind(this);
@@ -495,26 +495,26 @@ DeveloperToolbar.prototype.hide = functi
return this._hidePromise;
};
/**
* The devtools-unloaded event handler.
* @private
*/
DeveloperToolbar.prototype._devtoolsUnloaded = function() {
- let tabbrowser = this._chromeWindow.getBrowser();
+ let tabbrowser = this._chromeWindow.gBrowser;
Array.prototype.forEach.call(tabbrowser.tabs, this._stopErrorsCount, this);
};
/**
* The devtools-loaded event handler.
* @private
*/
DeveloperToolbar.prototype._devtoolsLoaded = function() {
- let tabbrowser = this._chromeWindow.getBrowser();
+ let tabbrowser = this._chromeWindow.gBrowser;
this._initErrorsCount(tabbrowser.selectedTab);
};
/**
* Initialize the listeners needed for tracking the number of errors for a given
* tab.
*
* @private
@@ -570,17 +570,17 @@ DeveloperToolbar.prototype._stopErrorsCo
/**
* Hide the developer toolbar
*/
DeveloperToolbar.prototype.destroy = function() {
if (this._input == null) {
return; // Already destroyed
}
- let tabbrowser = this._chromeWindow.getBrowser();
+ let tabbrowser = this._chromeWindow.gBrowser;
tabbrowser.tabContainer.removeEventListener("TabSelect", this, false);
tabbrowser.tabContainer.removeEventListener("TabClose", this, false);
tabbrowser.removeEventListener("load", this, true);
tabbrowser.removeEventListener("beforeunload", this, true);
Services.obs.removeObserver(this._devtoolsUnloaded, "devtools-unloaded");
Services.obs.removeObserver(this._devtoolsLoaded, "devtools-loaded");
Array.prototype.forEach.call(tabbrowser.tabs, this._stopErrorsCount, this);
@@ -619,17 +619,17 @@ DeveloperToolbar.prototype._notify = fun
/**
* Update various parts of the UI when the current tab changes
*/
DeveloperToolbar.prototype.handleEvent = function(ev) {
if (ev.type == "TabSelect" || ev.type == "load") {
if (this.visible) {
this.display.reattach({
- contentDocument: this._chromeWindow.getBrowser().contentDocument
+ contentDocument: this._chromeWindow.gBrowser.contentDocument
});
if (ev.type == "TabSelect") {
this._initErrorsCount(ev.target);
}
}
}
else if (ev.type == "TabClose") {
@@ -671,17 +671,17 @@ DeveloperToolbar.prototype._onPageError
* @param nsIDOMEvent ev the beforeunload DOM event.
*/
DeveloperToolbar.prototype._onPageBeforeUnload = function(ev) {
let window = ev.target.defaultView;
if (window.top !== window) {
return;
}
- let tabs = this._chromeWindow.getBrowser().tabs;
+ let tabs = this._chromeWindow.gBrowser.tabs;
Array.prototype.some.call(tabs, function(tab) {
if (tab.linkedBrowser.contentWindow === window) {
let tabId = tab.linkedPanel;
if (tabId in this._errorsCount || tabId in this._warningsCount) {
this._errorsCount[tabId] = 0;
this._warningsCount[tabId] = 0;
this._updateErrorsCount(tabId);
}
@@ -696,17 +696,17 @@ DeveloperToolbar.prototype._onPageBefore
* currently selected tab.
*
* @private
* @param string [changedTabId] Optional. The tab ID that had its page errors
* count changed. If this is provided and it doesn't match the currently
* selected tab, then the button is not updated.
*/
DeveloperToolbar.prototype._updateErrorsCount = function(changedTabId) {
- let tabId = this._chromeWindow.getBrowser().selectedTab.linkedPanel;
+ let tabId = this._chromeWindow.gBrowser.selectedTab.linkedPanel;
if (changedTabId && tabId != changedTabId) {
return;
}
let errors = this._errorsCount[tabId];
let warnings = this._warningsCount[tabId];
let btn = this._errorCounterButton;
if (errors) {
--- a/browser/fuel/fuelApplication.js
+++ b/browser/fuel/fuelApplication.js
@@ -89,17 +89,17 @@ function Window(aWindow) {
}
Window.prototype = {
get events() {
return this._events;
},
get _tabbrowser() {
- return this._window.getBrowser();
+ return this._window.gBrowser;
},
/*
* Helper used to setup event handlers on the XBL element. Note that the events
* are actually dispatched to tabs, so we capture them.
*/
_watch: function win_watch(aType) {
this._tabbrowser.tabContainer.addEventListener(aType, this,