Bug 829180 - Never open externally opened links in a private window; r=gavin
This commit is contained in:
@@ -7,6 +7,8 @@ Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "PrivateBrowsingUtils",
|
||||
"resource://gre/modules/PrivateBrowsingUtils.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "RecentWindow",
|
||||
"resource:///modules/RecentWindow.jsm");
|
||||
|
||||
const nsISupports = Components.interfaces.nsISupports;
|
||||
|
||||
@@ -297,13 +299,6 @@ function getMostRecentWindow(aType) {
|
||||
return wm.getMostRecentWindow(aType);
|
||||
}
|
||||
|
||||
// this returns the most recent non-popup browser window
|
||||
function getMostRecentBrowserWindow() {
|
||||
var browserGlue = Components.classes["@mozilla.org/browser/browserglue;1"]
|
||||
.getService(Components.interfaces.nsIBrowserGlue);
|
||||
return browserGlue.getMostRecentBrowserWindow();
|
||||
}
|
||||
|
||||
function doSearch(searchTerm, cmdLine) {
|
||||
var ss = Components.classes["@mozilla.org/browser/search-service;1"]
|
||||
.getService(nsIBrowserSearchService);
|
||||
@@ -735,7 +730,8 @@ function handURIToExistingBrowser(uri, location, cmdLine)
|
||||
if (!shouldLoadURI(uri))
|
||||
return;
|
||||
|
||||
var navWin = getMostRecentBrowserWindow();
|
||||
// Do not open external links in private windows
|
||||
var navWin = RecentWindow.getMostRecentBrowserWindow({private: false});
|
||||
if (!navWin) {
|
||||
// if we couldn't load it in an existing window, open a new one
|
||||
openWindow(null, gBrowserContentHandler.chromeURL, "_blank",
|
||||
|
||||
@@ -26,8 +26,13 @@ this.RecentWindow = {
|
||||
* in both groups, don't specify the private property.
|
||||
*/
|
||||
getMostRecentBrowserWindow: function RW_getMostRecentBrowserWindow(aOptions) {
|
||||
#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
let checkPrivacy = typeof aOptions == "object" &&
|
||||
"private" in aOptions;
|
||||
#else
|
||||
// In global PB builds, always ignore the requested privacy status
|
||||
let checkPrivacy = false;
|
||||
#endif
|
||||
|
||||
function isSuitableBrowserWindow(win) {
|
||||
return (!win.closed &&
|
||||
|
||||
Reference in New Issue
Block a user