Skip to content

Commit

Permalink
DND: make new (or target) tab private, if source or target are private
Browse files Browse the repository at this point in the history
+ rename "dragAndDropUseTargetPrivateState" => "dragAndDropBehavior"
(related to #4)
  • Loading branch information
Infocatcher committed Mar 25, 2013
1 parent 38d7513 commit 7d8a0d9
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 10 deletions.
32 changes: 23 additions & 9 deletions bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -487,9 +487,9 @@ var windowsObserver = {
_log(e.type + ": missing source node, ignore");
return;
}
var isPrivate = sourceNode == this.dndPrivateNode;
var isPrivateSource = sourceNode == this.dndPrivateNode;
this._dndPrivateNode = null;
_log(e.type + ": from " + (isPrivate ? "private" : "not private") + " tab");
_log(e.type + ": from " + (isPrivateSource ? "private" : "not private") + " tab");

var targetTab;
if(e.view.top == window) {
Expand Down Expand Up @@ -517,14 +517,28 @@ var windowsObserver = {
targetTab = window.gBrowser.selectedTab;
}

var origIsPrivate;
if(prefs.get("dragAndDropUseTargetPrivateState")) {
isPrivate = targetTab
? this.isPrivateTab(targetTab)
: this.isPrivateWindow(window);
_log("Will use target private state (from " + (targetTab ? "tab" : "window") + ")");
var isPrivateTarget = targetTab
? this.isPrivateTab(targetTab)
: this.isPrivateWindow(window);
_log("Will use target private state (from " + (targetTab ? "tab" : "window") + ")");

var isPrivate;
var dndBehavior = prefs.get("dragAndDropBehavior", 0);
if(dndBehavior == 1) {
isPrivate = isPrivateSource;
_log("Will use source private state: " + isPrivateSource);
}
else if(dndBehavior == 2) {
isPrivate = isPrivateTarget;
_log("Will use target private state: " + isPrivateTarget);
}
else if(targetTab && isPrivate != this.isPrivateTab(targetTab)) {
else {
isPrivate = isPrivateSource || isPrivateTarget;
_log("Will use source or target private state: " + isPrivateSource + " || " + isPrivateTarget);
}

var origIsPrivate;
if(targetTab && dndBehavior != 2 && isPrivate != this.isPrivateTab(targetTab)) {
origIsPrivate = !isPrivate;
_log(
"Dropped link may be opened in already existing tab, so make it "
Expand Down
5 changes: 4 additions & 1 deletion defaults/preferences/prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ pref("extensions.privateTab.keysIgnoreDefaultPrevented", false); // Ignore, if s
pref("extensions.privateTab.key.openNewPrivateTab", "control alt p");
pref("extensions.privateTab.key.toggleTabPrivate", "control alt v");

pref("extensions.privateTab.dragAndDropUseTargetPrivateState", false);
pref("extensions.privateTab.dragAndDropBehavior", 0);
// 0 - make new (or target) tab private, if source or target are private
// 1 - use source private state
// 2 - use target private state
pref("extensions.privateTab.dragAndDropTabsBetweenDifferentWindows", true);
pref("extensions.privateTab.rememberClosedPrivateTabs", false);
pref("extensions.privateTab.sendRefererHeader", 2);
Expand Down

0 comments on commit 7d8a0d9

Please sign in to comment.