[Pkg-mozext-commits] [tabmixplus] 02/30: Follow up bug 1113431 - Propagate referrer policy throughout the ui
David Prévot
taffit at moszumanska.debian.org
Sun Jun 14 22:15:34 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository tabmixplus.
commit a59738578fbb726aa567c735588e50d79d889954
Author: onemen <tabmix.onemen at gmail.com>
Date: Wed Mar 25 22:06:54 2015 +0200
Follow up bug 1113431 - Propagate referrer policy throughout the ui
---
chrome/content/content.js | 5 +++++
chrome/content/links/contentLinks.js | 9 +++++---
chrome/content/minit/tablib.js | 40 +++++++++++++++++++++++++-----------
chrome/content/places/places.js | 6 ++----
modules/ContentClick.jsm | 14 ++++++++++++-
5 files changed, 54 insertions(+), 20 deletions(-)
diff --git a/chrome/content/content.js b/chrome/content/content.js
index 82cb6b6..025f549 100644
--- a/chrome/content/content.js
+++ b/chrome/content/content.js
@@ -7,6 +7,8 @@ Cu.import("resource://gre/modules/XPCOMUtils.jsm", this);
// DocShellCapabilities exist since Firefox 27
XPCOMUtils.defineLazyModuleGetter(this, "DocShellCapabilities",
"resource:///modules/sessionstore/DocShellCapabilities.jsm");
+XPCOMUtils.defineLazyModuleGetter(this, "BrowserUtils",
+ "resource://gre/modules/BrowserUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "TabmixSvc",
"resource://tabmixplus/Services.jsm");
@@ -151,6 +153,9 @@ var TabmixClickEventHandler = {
altKey: event.altKey, href: null, title: null,
bookmark: false };
+ if (TabmixSvc.version(380))
+ json.referrerPolicy = ownerDoc.referrerPolicy;
+
if (typeof event.tabmix_openLinkWithHistory == "boolean")
json.tabmix_openLinkWithHistory = true;
diff --git a/chrome/content/links/contentLinks.js b/chrome/content/links/contentLinks.js
index f91a51d..01fd131 100644
--- a/chrome/content/links/contentLinks.js
+++ b/chrome/content/links/contentLinks.js
@@ -26,9 +26,12 @@ Tabmix.contentAreaClick = {
' let doc = event.target.ownerDocument;\n' +
' let _url = Tabmix.isVersion(190) ? href : url;\n' +
' let params = { charset: doc.characterSet, initiatingDoc: doc,\n' +
- ' suppressTabsOnFileDownload: suppressTabsOnFileDownload };\n' +
- ' if (!Tabmix.isVersion(370) || !BrowserUtils.linkHasNoReferrer(linkNode))\n' +
- ' params.referrerURI = doc.documentURIObject;\n'+
+ ' suppressTabsOnFileDownload: suppressTabsOnFileDownload,\n' +
+ ' referrerURI: doc.documentURIObject };\n' +
+ ' if (Tabmix.isVersion(370)) {\n' +
+ ' params.referrerPolicy = doc.referrerPolicy;\n' +
+ ' params.noReferrer = BrowserUtils.linkHasNoReferrer(linkNode);\n' +
+ ' }\n' +
' openLinkIn(_url, where, params);\n' +
' }\n' +
' else\n $&'
diff --git a/chrome/content/minit/tablib.js b/chrome/content/minit/tablib.js
index e17409c..4baf516 100644
--- a/chrome/content/minit/tablib.js
+++ b/chrome/content/minit/tablib.js
@@ -51,7 +51,19 @@ var tablib = {
).toCode();
},
- _loadURIWithFlags: function(browser, uri, flags, referrer, charset, postdata) {
+ _loadURIWithFlags: function(browser, uri, params) {
+ let flags;
+ if (!Tabmix.isVersion(380)) {
+ flags = params;
+ params = {
+ referrerURI: arguments[3] || null,
+ charset: arguments[4] || null,
+ postdata: arguments[5] || null,
+ };
+ }
+ else
+ flags = params.flags;
+
var allowLoad = tablib.isException(browser.tabmix_allowLoad !== false ||
uri.match(/^javascript:/));
if (!allowLoad) {
@@ -69,15 +81,10 @@ var tablib = {
var isLockedTab = tab.hasAttribute("locked");
if (!allowLoad && !isBlankTab && isLockedTab) {
let isFlaged = function(flag) !!(flags & Ci.nsIWebNavigation[flag]);
- let params = {
- referrerURI: referrer || null,
- charset: charset || null,
- postdata: postdata || null,
- inBackground: false,
- allowThirdPartyFixup: isFlaged("LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP"),
- fromExternal: isFlaged("LOAD_FLAGS_FROM_EXTERNAL"),
- allowMixedContent: isFlaged("LOAD_FLAGS_ALLOW_MIXED_CONTENT")
- };
+ params.inBackground = false;
+ params.allowThirdPartyFixup = isFlaged("LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP");
+ params.fromExternal = isFlaged("LOAD_FLAGS_FROM_EXTERNAL");
+ params.allowMixedContent = isFlaged("LOAD_FLAGS_ALLOW_MIXED_CONTENT");
return gBrowser.loadOneTab(uri, params);
}
browser.tabmix_allowLoad = uri == "about:blank" || !isLockedTab;
@@ -564,6 +571,16 @@ var tablib = {
[fnName, arg] = Tabmix.isVersion(260) ? ["_openURIInNewTab", "aIsExternal"] :
["openURI", "isExternal"];
var _openURI = Tabmix.changeCode(fnObj, "nsBrowserAccess.prototype." + fnName);
+
+ var loadURIWithFlags = Tabmix.isVersion(380) ?
+ ' gBrowser.loadURIWithFlags(aURI.spec, {\n' +
+ ' flags: loadflags,\n' +
+ ' referrerURI: aReferrer,\n' +
+ ' referrerPolicy: aReferrerPolicy,\n' +
+ ' });' :
+ ' browser.loadURIWithFlags(aURI.spec, loadflags, referrer, null, null);'
+ .replace("referrer", (Tabmix.isVersion(360) ? "aReferrer" : "referrer"));
+
_openURI = _openURI._replace(
'if (#1 && (!aURI || aURI.spec == "about:blank")) {'.replace("#1", arg),
'let currentIsBlank = win.gBrowser.isBlankNotBusyTab(win.gBrowser.mCurrentTab); \
@@ -586,8 +603,7 @@ var tablib = {
' let loadflags = #1 ?'.replace("#1", arg) +
' Ci.nsIWebNavigation.LOAD_FLAGS_FROM_EXTERNAL :' +
' Ci.nsIWebNavigation.LOAD_FLAGS_NONE;' +
- ' browser.loadURIWithFlags(aURI.spec, loadflags, referrer, null, null);'
- .replace("referrer", (Tabmix.isVersion(360) ? "aReferrer" : "referrer")) +
+ '\n' + loadURIWithFlags + '\n ' +
' browser.focus();' +
'}'
);
diff --git a/chrome/content/places/places.js b/chrome/content/places/places.js
index 682accd..88a169d 100644
--- a/chrome/content/places/places.js
+++ b/chrome/content/places/places.js
@@ -98,14 +98,12 @@ var TMP_Places = {
/Services.ww.openWindow[^;]*;/,
'let newWin = $&\n if (newWin && bookMarkId)\n newWin.bookMarkIds = bookMarkId;'
)._replace(
- /w\.gBrowser\.loadURIWithFlags\(.*\);/,
- '$&\n ' +
- 'w.gBrowser.ensureTabIsVisible(w.gBrowser.selectedTab);'
- )._replace(
/(\})(\)?)$/,
' var tab = where == "current" ?\n' +
' w.gBrowser.selectedTab : w.gBrowser.getTabForLastPanel();\n' +
' w.TMP_Places.setTabTitle(tab, url, bookMarkId);\n' +
+ ' if (where == "current")' +
+ ' w.gBrowser.ensureTabIsVisible(w.gBrowser.selectedTab);' +
'$1$2'
).toCode();
diff --git a/modules/ContentClick.jsm b/modules/ContentClick.jsm
index 7dbe354..b92f29f 100644
--- a/modules/ContentClick.jsm
+++ b/modules/ContentClick.jsm
@@ -12,6 +12,9 @@ XPCOMUtils.defineLazyModuleGetter(this, "PrivateBrowsingUtils",
XPCOMUtils.defineLazyModuleGetter(this, "Services",
"resource://gre/modules/Services.jsm");
+XPCOMUtils.defineLazyModuleGetter(this, "BrowserUtils",
+ "resource://gre/modules/BrowserUtils.jsm");
+
XPCOMUtils.defineLazyModuleGetter(this, "LinkNodeUtils",
"resource://tabmixplus/LinkNodeUtils.jsm");
@@ -154,6 +157,8 @@ var ContentClickInternal = {
let win = browser.ownerDocument.defaultView;
win.openLinkIn(href, result.where, {
referrerURI: browser.documentURI,
+ referrerPolicy: event.referrerPolicy,
+ noReferrer: event.noReferrer,
charset: browser.characterSet,
suppressTabsOnFileDownload: result.suppressTabsOnFileDownload
});
@@ -449,11 +454,18 @@ var ContentClickInternal = {
if (typeof aEvent.tabmix_openLinkWithHistory == "boolean")
return "2";
- let win = aBrowser.ownerDocument.defaultView;
+ let ownerDoc = aBrowser.ownerDocument;
+ let win = ownerDoc.defaultView;
let [href, linkNode] = win.hrefAndLinkNodeForClickEvent(aEvent);
if (!href) {
let node = LinkNodeUtils.getNodeWithOnClick(aEvent.target);
let wrappedOnClickNode = this.getWrappedNode(node, aFocusedWindow, aEvent.button === 0);
+ if (TabmixSvc.version(380)) {
+ aEvent.referrerPolicy = ownerDoc.referrerPolicy;
+ }
+ if (TabmixSvc.version(370)) {
+ aEvent.noReferrer = BrowserUtils.linkHasNoReferrer(node);
+ }
if (this.getHrefFromNodeOnClick(aEvent, aBrowser, wrappedOnClickNode))
aEvent.preventDefault();
return "2.1";
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/tabmixplus.git
More information about the Pkg-mozext-commits
mailing list