Bug 829180 - Never open externally opened links in a private window; r=gavin

This commit is contained in:
Ehsan Akhgari
2013-01-10 23:25:56 -05:00
parent d7df94cddc
commit 0c1f47cd5d
2 changed files with 9 additions and 8 deletions

View File

@@ -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",

View File

@@ -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 &&