Bug 1319157 - Check each URIs for home button. r=Gijs

This commit is contained in:
Tooru Fujisawa 2018-02-28 10:36:43 +09:00
Родитель dab0695a9b
Коммит 869b614794
3 изменённых файлов: 41 добавлений и 1 удалений

Просмотреть файл

@ -3517,6 +3517,12 @@ var browserDragAndDrop = {
return Services.droppedLinkHandler.getTriggeringPrincipal(aEvent);
},
validateURIsForDrop(aEvent, aURIsCount, aURIs) {
return Services.droppedLinkHandler.validateURIsForDrop(aEvent,
aURIsCount,
aURIs);
},
dropLinks(aEvent, aDisallowInherit) {
return Services.droppedLinkHandler.dropLinks(aEvent, aDisallowInherit);
}
@ -3527,7 +3533,22 @@ var homeButtonObserver = {
// disallow setting home pages that inherit the principal
let links = browserDragAndDrop.dropLinks(aEvent, true);
if (links.length) {
setTimeout(openHomeDialog, 0, links.map(link => link.url).join("|"));
let urls = [];
for (let link of links) {
if (link.url.includes("|")) {
urls.push(...link.url.split("|"));
} else {
urls.push(link.url);
}
}
try {
browserDragAndDrop.validateURIsForDrop(aEvent, urls.length, urls);
} catch (e) {
return;
}
setTimeout(openHomeDialog, 0, urls.join("|"));
}
},

Просмотреть файл

@ -279,6 +279,15 @@ ContentAreaDropListener.prototype =
return links;
},
validateURIsForDrop: function(aEvent, aURIsCount, aURIs, aDisallowInherit)
{
let dataTransfer = aEvent.dataTransfer;
for (let uri of aURIs) {
this._validateURI(dataTransfer, uri, aDisallowInherit);
}
},
queryLinks: function(aDataTransfer, aCount)
{
let links = this._getDropLinks(aDataTransfer);

Просмотреть файл

@ -80,6 +80,16 @@ interface nsIDroppedLinkHandler : nsISupports
[optional] out unsigned long aCount,
[retval, array, size_is(aCount)] out nsIDroppedLinkItem aLinks);
/**
* Given a drop event aEvent, validate the extra URIs for the event,
* this is used when the caller extracts yet another URIs from the dropped
* text, like home button that splits the text with "|".
*/
void validateURIsForDrop(in nsIDOMDragEvent aEvent,
in unsigned long aURIsCount,
[array, size_is(aURIsCount)] in wstring aURIs,
[optional] in boolean aDisallowInherit);
/**
* Given a dataTransfer, allows caller to determine and verify links being
* dragged. Since drag/drop performs a roundtrip of parent, child, parent,