Bug 819274 - Disable the Restore Previous Session command for private windows in per-window PB builds; r=dao

This commit is contained in:
Ehsan Akhgari 2012-12-09 23:13:50 -05:00
parent ee1987242b
commit cd0828939e
5 changed files with 18 additions and 24 deletions

View File

@ -309,10 +309,8 @@
disabled="true"/>
#endif
<menuitem id="appmenu_restoreLastSession"
class="restoreLastSession"
label="&historyRestoreLastSession.label;"
oncommand="restoreLastSession();"
disabled="true"/>
command="Browser:RestoreLastSession"/>
<menu id="appmenu_recentlyClosedTabsMenu"
class="recentlyClosedTabsMenu"
label="&historyUndoMenu.label;"

View File

@ -376,10 +376,8 @@
disabled="true"/>
#endif
<menuitem id="historyRestoreLastSession"
class="restoreLastSession"
label="&historyRestoreLastSession.label;"
oncommand="restoreLastSession();"
disabled="true"/>
command="Browser:RestoreLastSession"/>
<menu id="historyUndoMenu"
class="recentlyClosedTabsMenu"
label="&historyUndoMenu.label;"

View File

@ -660,15 +660,6 @@ HistoryMenu.prototype = {
#endif
},
toggleRestoreLastSession: function PHM_toggleRestoreLastSession() {
let restoreItem = this._rootElt.getElementsByClassName("restoreLastSession")[0];
if (this._ss.canRestoreLastSession)
restoreItem.removeAttribute("disabled");
else
restoreItem.setAttribute("disabled", true);
},
_onPopupShowing: function HM__onPopupShowing(aEvent) {
PlacesMenu.prototype._onPopupShowing.apply(this, arguments);
@ -679,7 +670,6 @@ HistoryMenu.prototype = {
this.toggleRecentlyClosedTabs();
this.toggleRecentlyClosedWindows();
this.toggleTabsFromOtherComputers();
this.toggleRestoreLastSession();
},
_onCommand: function HM__onCommand(aEvent) {

View File

@ -85,6 +85,7 @@
<command id="cmd_fullZoomReset" oncommand="FullZoom.reset()"/>
<command id="cmd_fullZoomToggle" oncommand="ZoomManager.toggleZoom();"/>
<command id="Browser:OpenLocation" oncommand="openLocation();"/>
<command id="Browser:RestoreLastSession" oncommand="restoreLastSession();" disabled="true"/>
<command id="Tools:Search" oncommand="BrowserSearch.webSearch();"/>
<command id="Tools:Downloads" oncommand="BrowserDownloadsUI();"/>

View File

@ -1318,13 +1318,16 @@ var gBrowserInit = {
#endif
// initialize the session-restore service (in case it's not already running)
try {
Cc["@mozilla.org/browser/sessionstore;1"]
.getService(Ci.nsISessionStore)
.init(window);
} catch (ex) {
dump("nsSessionStore could not be initialized: " + ex + "\n");
}
let ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
ss.init(window);
// Enable the Restore Last Session command if needed
if (ss.canRestoreLastSession
#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
&& !PrivateBrowsingUtils.isWindowPrivate(window)
#endif
)
goSetCommandEnabled("Browser:RestoreLastSession", true);
PlacesToolbarHelper.init();
@ -2458,7 +2461,11 @@ function BrowserOnAboutPageLoad(document) {
let ss = Components.classes["@mozilla.org/browser/sessionstore;1"].
getService(Components.interfaces.nsISessionStore);
if (ss.canRestoreLastSession)
if (ss.canRestoreLastSession
#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
&& !PrivateBrowsingUtils.isWindowPrivate(window)
#endif
)
document.getElementById("launcher").setAttribute("session", "true");
// Inject search engine and snippets URL.