[Pkg-mozext-commits] [requestpolicy] 65/280: add two methods to `NormalRequest.prototype`
David Prévot
taffit at moszumanska.debian.org
Sat May 2 20:30:00 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository requestpolicy.
commit 697585cfcfc280fb7c1fda9ea21fe23e8e95500a
Author: Martin Kimmerle <dev at 256k.de>
Date: Thu Dec 25 16:17:43 2014 +0100
add two methods to `NormalRequest.prototype`
add `getBrowser` and `getChromeWindow` to `NormalRequest`
---
src/content/lib/request.jsm | 34 +++++++++++++++++++++++++++++-----
1 file changed, 29 insertions(+), 5 deletions(-)
diff --git a/src/content/lib/request.jsm b/src/content/lib/request.jsm
index 8cd35e6..6efec6b 100644
--- a/src/content/lib/request.jsm
+++ b/src/content/lib/request.jsm
@@ -197,7 +197,7 @@ NormalRequest.prototype.isInternal = function() {
};
/**
- * Get the nsIDOMWindow related to this request.
+ * Get the content window (nsIDOMWindow) related to this request.
*/
NormalRequest.prototype.getContentWindow = function() {
let context = this.aContext;
@@ -228,6 +228,30 @@ NormalRequest.prototype.getContentWindow = function() {
return win;
};
+/**
+ * Get the chrome window (nsIDOMWindow) related to this request.
+ */
+NormalRequest.prototype.getChromeWindow = function() {
+ let contentWindow = this.getContentWindow();
+ if (!!contentWindow) {
+ return Utils.getChromeWindow(contentWindow);
+ } else {
+ return null;
+ }
+};
+
+/**
+ * Get the <browser> (nsIDOMXULElement) related to this request.
+ */
+NormalRequest.prototype.getBrowser = function() {
+ let context = this.aContext;
+ if (context instanceof Ci.nsIDOMXULElement && context.tagName === "browser") {
+ return context;
+ } else {
+ return Utils.getBrowserForWindow(this.getContentWindow());
+ }
+};
+
// see https://github.com/RequestPolicyContinued/requestpolicy/issues/447
var knownSchemesWithoutHost = [
@@ -303,11 +327,11 @@ NormalRequest.prototype.checkURISchemes = function() {
"uncatched scheme '" + scheme + "'. The request is from <" +
this.originURI + "> to <" + this.destURI + "> ");
try {
- let win = this.getContentWindow();
- if (!win) {
- throw "The window could not be extracted from aContext.";
+ let chromeWin = this.getChromeWindow();
+ if (!chromeWin) {
+ throw "The chrome window could not be extracted from aContext.";
}
- let overlay = Utils.getChromeWindow(win).requestpolicy.overlay;
+ let overlay = chromeWin.requestpolicy.overlay;
Utils.runAsync(function() {
overlay.showSchemeNotification(win, scheme);
});
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/requestpolicy.git
More information about the Pkg-mozext-commits
mailing list