Moderator: fddima
BdC wrote:Is there any short term plan to add support for CefRegisterExtension in CefGlue/3?
orsox wrote:Great Work!
Could you please post cef-binaries for your latest update to r778!?
Keep up the good work!
steven181 wrote:Hi
May I know there is any solution to use RegisterScriptableObject with CEF3.
Thanks for your support.
Steven
fddima wrote:steven181 wrote:Hi
May I know there is any solution to use RegisterScriptableObject with CEF3.
Thanks for your support.
Steven
For new questions - better create new post (new thread).
No, currently CefGlue3 doesn't expose any of this functionality. But may be better / simplier is make own custom scheme handler, and interact with this handler via standard XHR (XMLHttpRequest) from javascript.
protected override bool ProcessRequest(CefRequest request, CefCallback callback)
{
var urlString = request.Url;
this._redirectUrl = urlString;
string errorMessage = null;
int errorStatus = 0;
string errorStatusText = null;
try
{
var uri = new Uri(urlString);
var path = uri.Host + uri.AbsolutePath; // ignore host
var asm = typeof(ClientSchemeHandler).Assembly;
var resPrefix = "CefGlue.Client.Resources.";
var resName = "test";
var bytes1 = Encoding.UTF8.GetBytes(resName);
this.stream = new MemoryStream(bytes1, false);
if (this.stream != null)
{
// found
this.responseLength = -1;
this.status = 200;
this.statusText = "OK";
this.mimeType = GetMimeTypeFromUriSuffix(path);
callback.Continue();
return true;
}
}
catch (Exception ex)
{
errorStatus = 500;
errorStatusText = "Internal Error";
errorMessage = "test<!doctype html><html><body><h1>Internal Error!</h1><pre>" + ex.ToString() + "</pre></body></html>";
}
// not found or error while processing request
errorMessage = errorMessage ?? "<!doctype html><html><body><h1>Not Found!</h1><p>The requested url [" + urlString + "] not found!</p></body></html>";
var bytes = Encoding.UTF8.GetBytes(errorMessage);
this.stream = new MemoryStream(bytes, false);
this.responseLength = -1;
this.status = errorStatus != 0 ? errorStatus : 404;
this.statusText = errorStatusText ?? "Not Found";
this.mimeType = "text/html";
callback.Continue();
return true;
}
function testAjax() {
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && xhr.status == 200) {
document.getElementById("ta").innerHTML = xhr.responseText;
}
};
xhr.open("GET", "res://tests/hello.html", true);
xhr.setRequestHeader('My-Custom-Header', 'Some Value');
xhr.send();
}
document.getElementById("ta").innerHTML = xhr.responseText;
Users browsing this forum: No registered users and 19 guests