}
try {
Xhr.post(message.getUrl(), payload, "application/json",
new Xhr.XhrCallback() {
public void onFail(XMLHttpRequest xhr) {
HeadlessSendDataAckMessage sendMessage = HeadlessSendDataAckMessage.create(false);
sendToContentScript(port, sendMessage);
}
public void onSuccess(XMLHttpRequest xhr) {
HeadlessSendDataAckMessage sendMessage = HeadlessSendDataAckMessage.create(true);
sendToContentScript(port, sendMessage);
}
});
} catch (JavaScriptException ex) {
console.log("XHR failed: " + ex);
HeadlessSendDataAckMessage sendMessage = HeadlessSendDataAckMessage.create(false);
sendToContentScript(port, sendMessage);
throw ex;
}
}