Skip to content

Commit

Permalink
Add pref to not set "privatebrowsingmode" attribute, if current tab i…
Browse files Browse the repository at this point in the history
…s private

(to disable private window-like styles)
May be useful on Linux and with Australis on Windows
(related to #40)
  • Loading branch information
Infocatcher committed Dec 14, 2013
1 parent 7a8e682 commit fb63ac9
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 17 deletions.
44 changes: 27 additions & 17 deletions bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,10 @@ var windowsObserver = {
|| pName == "rememberClosedPrivateTabs.enableCleanup"
)
this.addPbExitObserver(this.cleanupClosedPrivateTabs);
else if(pName == "usePrivateWindowStyle") {
for(var window in this.windows)
this.updateWindowTitle(window.gBrowser, undefined, true);
}
else if(pName == "debug")
_dbg = pVal;
else if(pName == "debug.verbose")
Expand Down Expand Up @@ -2892,7 +2896,7 @@ var windowsObserver = {
delete window._privateTabAppButtonWatcher;
}
},
updateWindowTitle: function(gBrowser, isPrivate) {
updateWindowTitle: function(gBrowser, isPrivate, force) {
var document = gBrowser.ownerDocument;
if(isPrivate === undefined)
isPrivate = this.isPrivateWindow(document.defaultView.content);
Expand All @@ -2902,7 +2906,7 @@ var windowsObserver = {
|| root.getAttribute("privateTab_titlemodifier_privatebrowsing")
: root.getAttribute("titlemodifier_normal")
|| root.getAttribute("privateTab_titlemodifier_normal");
if(root.getAttribute("titlemodifier") == tm)
if(!force && root.getAttribute("titlemodifier") == tm)
return;
_log("updateWindowTitle() " + tm);
root.setAttribute("titlemodifier", tm);
Expand All @@ -2912,21 +2916,27 @@ var windowsObserver = {
? root.getAttribute("title_privatebrowsing")
: root.getAttribute("title_normal")
);
if(isPrivate) {
var pbTemp = !PrivateBrowsingUtils.permanentPrivateBrowsing;
root.setAttribute("privatebrowsingmode", pbTemp ? "temporary" : "permanent");
pbTemp && this.fixAppButtonWidth(document);
}
else {
root.removeAttribute("privatebrowsingmode");
}
// See chrome://browser/content/browser.js, gPrivateBrowsingUI.init()
// http://hg.mozilla.org/mozilla-central/file/55f750590259/browser/base/content/browser.js#l6734
if(Services.appinfo.OS == "Darwin") {
if(isPrivate && pbTemp)
root.setAttribute("drawintitlebar", "true");
else
root.removeAttribute("drawintitlebar");
var usePrivateWindowStyle = prefs.get("usePrivateWindowStyle");
if(force || usePrivateWindowStyle) {
var indicatePrivate = usePrivateWindowStyle
? isPrivate
: this.isPrivateWindow(document.defaultView);
if(indicatePrivate) {
var pbTemp = !PrivateBrowsingUtils.permanentPrivateBrowsing;
root.setAttribute("privatebrowsingmode", pbTemp ? "temporary" : "permanent");
pbTemp && this.fixAppButtonWidth(document);
}
else {
root.removeAttribute("privatebrowsingmode");
}
// See chrome://browser/content/browser.js, gPrivateBrowsingUI.init()
// http://hg.mozilla.org/mozilla-central/file/55f750590259/browser/base/content/browser.js#l6734
if(Services.appinfo.OS == "Darwin") {
if(indicatePrivate && pbTemp)
root.setAttribute("drawintitlebar", "true");
else
root.removeAttribute("drawintitlebar");
}
}
gBrowser.updateTitlebar();
this.privateChanged(document, isPrivate);
Expand Down
3 changes: 3 additions & 0 deletions defaults/preferences/prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ pref("extensions.privateTab.fixAppButtonWidth", true);
pref("extensions.privateTab.patchDownloads", true);
pref("extensions.privateTab.enablePrivateProtocol", true);
pref("extensions.privateTab.showItemInTaskBarJumpList", true); // Works only if enablePrivateProtocol == true
pref("extensions.privateTab.usePrivateWindowStyle", true);
// true - apply private window style to private tabs (and show tab private state)
// false - show window private state

pref("extensions.privateTab.debug", false);
pref("extensions.privateTab.debug.verbose", false);

0 comments on commit fb63ac9

Please sign in to comment.