cef/libcef_dll/cpptoc/v8handler_cpptoc.cc
Marshall Greenblatt c295931b1e - Move frame-related methods from CefBrowser into a new CefFrame class.
- Add CefBrowser::Get*Frame() methods for retrieving the appropriate CefFrame instance.
- Add a CefFrame attribute to CefHandler callback methods where appropriate.
- Add support for V8 JavaScript extensions and values via CefV8Value and CefV8Handler.  Native C++ and user-defined JavaScript object hierarchies may now be created and accessed using the CEF API.
- Remove the CefHandler and CefVariant classes and related CefBrowser methods that have been obsoleted by the addition of CEF V8 support.
- Add the CefRegisterExtension() function for registering system-wide V8 extensions.
- Add the CefHandler::HandleJSBinding() callback method for attaching V8 values to the global frame JavaScript object.  This method replaces the previous technique of calling CefBrowser::AddJSHandler().
- Add new wrapper template methods for simplifying DLL wrapper implementations.
- Move cef_string* files from libcef_dll to libcef so that projects can link libcef statically without errors.
- Fix crashes when CEF exits due to object constructors being executed on non-UI threads if the application is closed while a page is still loading.
- Update the cefclient project to reflect changes and demonstrate the new APIs.

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@26 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
2009-05-28 00:31:21 +00:00

55 lines
1.5 KiB
C++

// Copyright (c) 2009 The Chromium Embedded Framework 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 "../precompiled_libcef.h"
#include "cpptoc/v8handler_cpptoc.h"
#include "ctocpp/v8value_ctocpp.h"
int CEF_CALLBACK v8handler_execute(struct _cef_v8handler_t* v8handler,
const wchar_t* name, struct _cef_v8value_t* object, size_t numargs,
struct _cef_v8value_t** args, struct _cef_v8value_t** retval,
cef_string_t* exception)
{
DCHECK(v8handler);
if(!v8handler)
return RV_CONTINUE;
CefRefPtr<CefV8Value> objectPtr;
if(object)
objectPtr = CefV8ValueCToCpp::Wrap(object);
std::wstring nameStr;
if(name)
nameStr = name;
CefV8ValueList list;
for(size_t i = 0; i < numargs; ++i)
list.push_back(CefV8ValueCToCpp::Wrap(args[i]));
CefRefPtr<CefV8Value> retValPtr;
std::wstring exceptionStr;
bool rv = CefV8HandlerCppToC::Get(v8handler)->Execute(nameStr, objectPtr,
list, retValPtr, exceptionStr);
if(rv) {
if(!exceptionStr.empty() && exception)
*exception = cef_string_alloc(exceptionStr.c_str());
if(retValPtr.get() && retval)
*retval = CefV8ValueCToCpp::Unwrap(retValPtr);
}
return rv;
}
CefV8HandlerCppToC::CefV8HandlerCppToC(CefV8Handler* cls)
: CefCppToC<CefV8HandlerCppToC, CefV8Handler, cef_v8handler_t>(cls)
{
struct_.struct_.execute = v8handler_execute;
}
#ifdef _DEBUG
long CefCppToC<CefV8HandlerCppToC, CefV8Handler, cef_v8handler_t>::DebugObjCt
= 0;
#endif