mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 601695 - Paste & Go should only appear when clipboard is URL; r=dao a=blocking2.0-final+
This commit is contained in:
parent
878becc3e3
commit
8e7f9d5b9b
@ -130,11 +130,24 @@
|
||||
if (!pasteAndGo)
|
||||
return;
|
||||
var controller = document.commandDispatcher.getControllerForCommand("cmd_paste");
|
||||
var enabled = controller.isCommandEnabled("cmd_paste");
|
||||
if (enabled)
|
||||
pasteAndGo.removeAttribute("disabled");
|
||||
else
|
||||
pasteAndGo.setAttribute("disabled", "true");
|
||||
var couldBeURL = controller.isCommandEnabled("cmd_paste");
|
||||
if (couldBeURL) {
|
||||
let cbSvc = Cc["@mozilla.org/widget/clipboard;1"].
|
||||
getService(Ci.nsIClipboard);
|
||||
let xferable = Cc["@mozilla.org/widget/transferable;1"].
|
||||
createInstance(Ci.nsITransferable);
|
||||
xferable.addDataFlavor("text/unicode");
|
||||
cbSvc.getData(xferable, cbSvc.kGlobalClipboard);
|
||||
let data = {};
|
||||
xferable.getTransferData("text/unicode", data, {});
|
||||
data = data.value.QueryInterface(Ci.nsISupportsString).data;
|
||||
try {
|
||||
makeURI(data);
|
||||
} catch (ex) { // clipboard data is not a URL
|
||||
couldBeURL = false;
|
||||
}
|
||||
}
|
||||
pasteAndGo.hidden = !couldBeURL;
|
||||
}, false);
|
||||
|
||||
var insertLocation = cxmenu.firstChild;
|
||||
|
Loading…
Reference in New Issue
Block a user