2018-09-10 02:41:13 +02:00
|
|
|
// Copyright © 2014 The CefSharp Authors. All rights reserved.
|
2014-04-05 19:47:42 +03:00
|
|
|
//
|
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
|
|
|
|
|
|
2015-03-08 12:51:33 +01:00
|
|
|
#pragma once
|
2014-04-05 19:47:42 +03:00
|
|
|
|
2014-04-08 18:56:11 +01:00
|
|
|
#include "include/cef_v8.h"
|
2015-03-08 13:11:09 +01:00
|
|
|
#include "JavascriptCallbackRegistry.h"
|
2014-04-08 18:56:11 +01:00
|
|
|
|
2020-07-18 13:30:54 +10:00
|
|
|
using namespace CefSharp::Internals::Wcf;
|
|
|
|
|
|
2014-04-05 19:47:42 +03:00
|
|
|
namespace CefSharp
|
|
|
|
|
{
|
2021-02-27 12:11:35 +10:00
|
|
|
namespace BrowserSubprocess
|
2014-04-05 19:47:42 +03:00
|
|
|
{
|
2021-02-27 12:11:35 +10:00
|
|
|
private class JavascriptMethodHandler : public CefV8Handler
|
2015-07-09 10:55:12 +10:00
|
|
|
{
|
2021-02-27 12:11:35 +10:00
|
|
|
private:
|
|
|
|
|
gcroot<Func<array<Object^>^, BrowserProcessResponse^>^> _method;
|
|
|
|
|
gcroot<JavascriptCallbackRegistry^> _callbackRegistry;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
JavascriptMethodHandler(Func<array<Object^>^, BrowserProcessResponse^>^ method, JavascriptCallbackRegistry^ callbackRegistry)
|
|
|
|
|
{
|
|
|
|
|
_method = method;
|
|
|
|
|
_callbackRegistry = callbackRegistry;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
~JavascriptMethodHandler()
|
|
|
|
|
{
|
|
|
|
|
delete _method;
|
|
|
|
|
// The callback registry is a shared instance among all method handlers (async & sync).
|
|
|
|
|
// It's lifecycle is managed in the JavascriptRootObjectWrapper.
|
|
|
|
|
_callbackRegistry = nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-31 15:24:13 +10:00
|
|
|
virtual bool Execute(const CefString& name, CefRefPtr<CefV8Value> object, const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval, CefString& exception) override;
|
2021-02-27 12:11:35 +10:00
|
|
|
|
|
|
|
|
CefRefPtr<CefV8Value> ConvertToCefObject(Object^ obj);
|
|
|
|
|
|
2021-09-03 10:51:18 +10:00
|
|
|
IMPLEMENT_REFCOUNTINGM(JavascriptMethodHandler);
|
2021-02-27 12:11:35 +10:00
|
|
|
};
|
|
|
|
|
}
|
2019-04-26 06:44:18 +10:00
|
|
|
}
|