commit ca8220118f1e3ac3ed190cc15f1091f285cf299a
Author: Georg Koppen <gk(a)torproject.org>
Date: Thu Sep 18 13:14:36 2014 +0000
Bug 10716: Take care of drag/drop events in ESR 31.
---
src/components/external-app-blocker.js | 31 +++++++++++++++++++++++++++++--
1 file changed, 29 insertions(+), 2 deletions(-)
diff --git a/src/components/external-app-blocker.js b/src/components/external-app-blocker.js
index 38ddcd7..aed25ce 100644
--- a/src/components/external-app-blocker.js
+++ b/src/components/external-app-blocker.js
@@ -61,6 +61,7 @@ function ExternalWrapper() {
var observerService = Cc["@mozilla.org/observer-service;1"].
getService(Ci.nsIObserverService);
observerService.addObserver(this, "on-modify-drag-list", false);
+ observerService.addObserver(this, "on-datatransfer-available", false);
} catch(e) {
this.logger.log(5, "Failed to register drag observer");
}
@@ -204,7 +205,7 @@ ExternalWrapper.prototype =
},
observe: function(subject, topic, data) {
- if(topic == "on-modify-drag-list") {
+ if (topic == "on-modify-drag-list") {
this.logger.log(3, "Got drag observer event");
try {
subject.QueryInterface(Ci.nsISupportsArray);
@@ -213,6 +214,9 @@ ExternalWrapper.prototype =
}
return this.filterDragURLs(subject);
+ } else if (topic == "on-datatransfer-available") {
+ this.logger.log(3, "The DataTransfer is available");
+ return this.filterDataTransferURLs(subject);
}
},
@@ -226,7 +230,7 @@ ExternalWrapper.prototype =
.QueryInterface(Ci.nsISupportsArray);
for (var f=0; f < flavors.Count(); f++) {
- var flavor =flavors.GetElementAt(f);
+ var flavor =flavors.GetElementAt(f);
flavor.QueryInterface(Ci.nsISupportsCString);
this.logger.log(3, "Got drag+drop flavor: "+flavor);
@@ -241,6 +245,29 @@ ExternalWrapper.prototype =
}
},
+ filterDataTransferURLs: function(aDataTransfer) {
+ var types = null;
+ var type = "";
+ var count = aDataTransfer.mozItemCount;
+ var len = 0;
+ for (var i = 0; i < count; ++i) {
+ this.logger.log(3, "Inspecting the data transfer: " + i);
+ types = aDataTransfer.mozTypesAt(i);
+ len = types.length;
+ for (var j = 0; j < len; ++j) {
+ type = types[j];
+ this.logger.log(3, "Type is: " + type);
+ if (type == "text/x-moz-url" ||
+ type == "text/x-moz-url-data" ||
+ type == "text/uri-list" ||
+ type == "application/x-moz-file-promise-url") {
+ aDataTransfer.clearData(type);
+ this.logger.log(3, "Removing " + type);
+ }
+ }
+ }
+ }
+
};
var ExternalWrapperSingleton = null;