[Pkg-mozext-commits] [requestpolicy] 228/280: fix an issue in `checkURISchemes`
David Prévot
taffit at moszumanska.debian.org
Sat May 2 20:30:32 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 757a78ced6df605456c64d35cc697cc05b49a1b5
Author: Martin Kimmerle <dev at 256k.de>
Date: Wed Mar 18 19:46:27 2015 +0100
fix an issue in `checkURISchemes`
---
src/content/lib/request.jsm | 38 +++++++++++++++++++++++++++++++-------
src/content/lib/utils.jsm | 5 +++--
2 files changed, 34 insertions(+), 9 deletions(-)
diff --git a/src/content/lib/request.jsm b/src/content/lib/request.jsm
index 8acbfbf..ad010e9 100644
--- a/src/content/lib/request.jsm
+++ b/src/content/lib/request.jsm
@@ -340,21 +340,45 @@ NormalRequest.prototype.checkURISchemes = function() {
Logger.warning(Logger.TYPE_CONTENT,
"uncatched scheme '" + scheme + "'. The request is from <" +
this.originURI + "> to <" + this.destURI + "> ");
+
+ let chromeWin, browser;
try {
- let chromeWin = this.getChromeWindow();
+ chromeWin = this.getChromeWindow();
if (!chromeWin) {
throw "The chrome window could not be extracted from aContext.";
}
- let overlay = chromeWin.requestpolicy.overlay;
- let browser = this.getBrowser();
- Utils.runAsync(function() {
- overlay.showSchemeNotification(browser, scheme);
- });
+ browser = this.getBrowser();
} catch (e) {
- Logger.warning(Logger.TYPE_ERROR,
+ Logger.warning(Logger.TYPE_INTERNAL,
"The user could not be informed about the " +
"unknown scheme. Error was: " + e, e);
}
+
+ // Try showing the notification multiple times. This is done
+ // async for two reasons:
+ // (a) The chrome window's overlay might not be initialized
+ // yet.
+ // (b) This function is called by the request processor, so
+ // it should terminate asap.
+ Utils.tryMultipleTimes(function (aTriesLeft) {
+ try {
+ let overlay = chromeWin.requestpolicy.overlay;
+ overlay.showSchemeNotification(browser, scheme);
+ return true;
+ } catch (e) {
+ if (aTriesLeft === 0) {
+ Logger.warning(Logger.TYPE_INTERNAL,
+ "Failed to show the scheme notification. " +
+ "Error was: " + e, e);
+ } else {
+ Logger.warning(Logger.TYPE_INTERNAL,
+ "Failed to show the scheme notification. " +
+ "Trying again...");
+ }
+ return false;
+ }
+ }, 3);
+
}
return {shouldLoad: unknownSchemesDetected ? false : null};
diff --git a/src/content/lib/utils.jsm b/src/content/lib/utils.jsm
index c84bd12..10ff720 100644
--- a/src/content/lib/utils.jsm
+++ b/src/content/lib/utils.jsm
@@ -87,9 +87,10 @@ let Utils = (function() {
//console.log("no more tries!");
return;
}
+ let triesLeft = aTries - 1;
self.runAsync(function() {
- if (aFunction.call(null) !== true) {
- self.tryMultipleTimes(aFunction, aTries - 1);
+ if (aFunction.call(null, triesLeft) !== true) {
+ self.tryMultipleTimes(aFunction, triesLeft);
}
});
};
--
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