mirror of
https://github.com/cefsharp/CefSharp.git
synced 2026-12-04 08:03:22 +00:00
7128e40fd1
Throw in a couple of tab containing files for good measure. Evil tabs, evil I say.
58 lines
1.8 KiB
C++
58 lines
1.8 KiB
C++
// Copyright © 2010-2015 The CefSharp Authors. All rights reserved.
|
|
//
|
|
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
|
|
|
|
#include "stdafx.h"
|
|
#include "TypeUtils.h"
|
|
#include "JavascriptCallbackWrapper.h"
|
|
|
|
namespace CefSharp
|
|
{
|
|
namespace Internals
|
|
{
|
|
JavascriptCallbackWrapper::~JavascriptCallbackWrapper()
|
|
{
|
|
value = nullptr;
|
|
context = nullptr;
|
|
}
|
|
|
|
JavascriptResponse^ JavascriptCallbackWrapper::Execute(array<Object^>^ parms)
|
|
{
|
|
JavascriptResponse^ response = nullptr;
|
|
if (context->Enter())
|
|
{
|
|
response = gcnew JavascriptResponse();
|
|
try
|
|
{
|
|
CefV8ValueList args;
|
|
for each (auto parm in parms)
|
|
{
|
|
auto cefParm = TypeUtils::ConvertToCef(parm, nullptr);
|
|
args.push_back(cefParm);
|
|
}
|
|
|
|
auto retval = value->ExecuteFunctionWithContext(context.get(), nullptr, args);
|
|
response->Success = retval != nullptr;
|
|
if (response->Success)
|
|
{
|
|
response->Result = TypeUtils::ConvertFromCef(retval);
|
|
}
|
|
else
|
|
{
|
|
auto exception = value->GetException();
|
|
if (exception.get())
|
|
{
|
|
response->Message = StringUtils::ToClr(exception->GetMessage());
|
|
}
|
|
}
|
|
}
|
|
finally
|
|
{
|
|
context->Exit();
|
|
}
|
|
}
|
|
return response;
|
|
}
|
|
}
|
|
}
|