From 2c32c7881224fb0a8d75ba8ccbefd4ba4e9060f7 Mon Sep 17 00:00:00 2001 From: Andres Hernandez Date: Tue, 20 Nov 2012 19:31:35 -0600 Subject: [PATCH] Bug 722993 - WindowsJumpLists.jsm uses global Private Browsing state to make decisions; f=jdm, r=ehsan --- browser/components/nsBrowserContentHandler.js | 9 ++++++ browser/modules/Makefile.in | 2 ++ browser/modules/WindowsJumpLists.jsm | 29 +++++++++++++++---- 3 files changed, 35 insertions(+), 5 deletions(-) diff --git a/browser/components/nsBrowserContentHandler.js b/browser/components/nsBrowserContentHandler.js index c4a0de12f3c..c09020bbd43 100644 --- a/browser/components/nsBrowserContentHandler.js +++ b/browser/components/nsBrowserContentHandler.js @@ -516,8 +516,17 @@ nsBrowserContentHandler.prototype = { } if (cmdLine.handleFlag("silent", false)) cmdLine.preventDefault = true; +#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING + if (cmdLine.findFlag("private-window", false) >= 0) { + openWindow(null, this.chromeURL, "_blank", + "chrome,dialog=no,private,all" + this.getFeatures(cmdLine), + "about:privatebrowsing"); + cmdLine.preventDefault = true; + } +#else if (cmdLine.findFlag("private-toggle", false) >= 0) cmdLine.preventDefault = true; +#endif var searchParam = cmdLine.handleFlagWithParam("search", false); if (searchParam) { diff --git a/browser/modules/Makefile.in b/browser/modules/Makefile.in index 95e5a79602b..edd840e0ee4 100644 --- a/browser/modules/Makefile.in +++ b/browser/modules/Makefile.in @@ -31,6 +31,8 @@ EXTRA_JS_MODULES = \ ifeq ($(MOZ_WIDGET_TOOLKIT),windows) EXTRA_JS_MODULES += \ WindowsPreviewPerTab.jsm \ + $(NULL) +EXTRA_PP_JS_MODULES = \ WindowsJumpLists.jsm \ $(NULL) endif diff --git a/browser/modules/WindowsJumpLists.jsm b/browser/modules/WindowsJumpLists.jsm index b4f098e14e7..8ddf505e920 100644 --- a/browser/modules/WindowsJumpLists.jsm +++ b/browser/modules/WindowsJumpLists.jsm @@ -74,9 +74,11 @@ XPCOMUtils.defineLazyServiceGetter(this, "_winShellService", "@mozilla.org/browser/shell-service;1", "nsIWindowsShellService"); +#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING XPCOMUtils.defineLazyServiceGetter(this, "_privateBrowsingSvc", "@mozilla.org/privatebrowsing;1", "nsIPrivateBrowsingService"); +#endif XPCOMUtils.defineLazyModuleGetter(this, "PrivateBrowsingUtils", "resource://gre/modules/PrivateBrowsingUtils.jsm"); @@ -104,7 +106,7 @@ var tasksCfg = [ * open - Boolean indicates if the command should be visible after the browser opens. * close - Boolean indicates if the command should be visible after the browser closes. */ - // Open new window + // Open new tab { get title() _getString("taskbar.tasks.newTab.label"), get description() _getString("taskbar.tasks.newTab.description"), @@ -116,7 +118,7 @@ var tasksCfg = [ // Thus true for consistency. }, - // Open new tab + // Open new window { get title() _getString("taskbar.tasks.newWindow.label"), get description() _getString("taskbar.tasks.newWindow.description"), @@ -124,9 +126,21 @@ var tasksCfg = [ iconIndex: 2, // New tab icon open: true, close: true, // No point, but we don't always update the list on - // shutdown. Thus true for consistency. + // shutdown. Thus true for consistency. }, +#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING + // Open new private window + { + get title() _getString("taskbar.tasks.newPrivateWindow.label"), + get description() _getString("taskbar.tasks.newPrivateWindow.description"), + args: "-private-window", + iconIndex: 4, // Private browsing mode icon + open: true, + close: true, // No point, but we don't always update the list on + // shutdown. Thus true for consistency. + }, +#else // Toggle the Private Browsing mode { get title() { @@ -152,6 +166,7 @@ var tasksCfg = [ return !PrivateBrowsingUtils.permanentPrivateBrowsing; }, }, +#endif ]; ///////////////////////////////////////////////////////////////////////////// @@ -514,7 +529,9 @@ this.WinTaskbarJumpList = }, _initObs: function WTBJL__initObs() { +#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING Services.obs.addObserver(this, "private-browsing", false); +#endif // If the browser is closed while in private browsing mode, the "exit" // notification is fired on quit-application-granted. // History cleanup can happen at profile-change-teardown. @@ -524,7 +541,9 @@ this.WinTaskbarJumpList = }, _freeObs: function WTBJL__freeObs() { +#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING Services.obs.removeObserver(this, "private-browsing"); +#endif Services.obs.removeObserver(this, "profile-before-change"); Services.obs.removeObserver(this, "browser:purge-session-history"); _prefs.removeObserver("", this); @@ -590,11 +609,11 @@ this.WinTaskbarJumpList = case "browser:purge-session-history": this.update(); break; - +#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING case "private-browsing": this.update(); break; - +#endif case "idle": if (this._timer) { this._timer.cancel();