Bug 611590 - Make "Paste & Go" consistent with "Paste" regardless of clipboard contents. r=gavin ui-r=faaborg a=betaN+gavin

This commit is contained in:
Frank Yan 2010-11-22 11:50:49 -08:00
parent f12a85806e
commit 4c9b151a50

View File

@ -130,24 +130,11 @@
if (!pasteAndGo)
return;
var controller = document.commandDispatcher.getControllerForCommand("cmd_paste");
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;
var enabled = controller.isCommandEnabled("cmd_paste");
if (enabled)
pasteAndGo.removeAttribute("disabled");
else
pasteAndGo.setAttribute("disabled", "true");
}, false);
var insertLocation = cxmenu.firstChild;