cef/libcef_dll/ctocpp/jshandler_ctocpp.cc
Marshall Greenblatt 35e21da884 Add DLL build support and wrapper that allows clients to transparently switch between static and dynamic CEF builds.
- The libcef project now builds libcef_static.lib instead of libcef.lib.
- The libcef_dll project builds libcef.lib and libcef.dll.  This DLL exports the new CEF C API defined in cef_capi.h, cef_nplugin_capi.h, cef_string.h and cef_string_map.h.
- The libcef_dll_wrapper project builds libcef_dll_wrapper.lib.  This static library wraps the new C API calls with an implementation of the CEF C++ interface as defined in cef.h and cef_nplugin.h.
- The cefclient project now uses the DLL instead of the static library.
- Type definitions have been moved from cef.h to cef_types.h so that they can be shared by both cef.h and cef_capi.h.  This change required some enumeration member name modifications throughout the code base.
- Fixed variable naming inconsistencies.
- Added CefVariant::GetArraySize() method and _NPN_ArrayObjectGetVectorSize() function.
- Remove the ProjectSection(WebsiteProperties) sections from cef.sln to improve VS2005 performance.

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@16 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
2009-03-05 01:10:06 +00:00

104 lines
3.3 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/browser_cpptoc.h"
#include "cpptoc/variant_cpptoc.h"
#include "ctocpp/jshandler_ctocpp.h"
#include "base/logging.h"
bool CefJSHandlerCToCpp::HasMethod(CefRefPtr<CefBrowser> browser,
const std::wstring& name)
{
if(CEF_MEMBER_MISSING(struct_, has_method))
return RV_CONTINUE;
CefBrowserCppToC* browserPtr = new CefBrowserCppToC(browser);
browserPtr->AddRef();
return struct_->has_method(struct_, browserPtr->GetStruct(), name.c_str());
}
bool CefJSHandlerCToCpp::HasProperty(CefRefPtr<CefBrowser> browser,
const std::wstring& name)
{
if(CEF_MEMBER_MISSING(struct_, has_method))
return RV_CONTINUE;
CefBrowserCppToC* browserPtr = new CefBrowserCppToC(browser);
browserPtr->AddRef();
return struct_->has_property(struct_, browserPtr->GetStruct(), name.c_str());
}
bool CefJSHandlerCToCpp::SetProperty(CefRefPtr<CefBrowser> browser,
const std::wstring& name,
const CefRefPtr<CefVariant> value)
{
if(CEF_MEMBER_MISSING(struct_, has_method))
return RV_CONTINUE;
CefBrowserCppToC* browserPtr = new CefBrowserCppToC(browser);
browserPtr->AddRef();
CefVariantCppToC* valuePtr = new CefVariantCppToC(value);
valuePtr->AddRef();
return struct_->set_property(struct_, browserPtr->GetStruct(), name.c_str(),
valuePtr->GetStruct());
}
bool CefJSHandlerCToCpp::GetProperty(CefRefPtr<CefBrowser> browser,
const std::wstring& name,
CefRefPtr<CefVariant> value)
{
if(CEF_MEMBER_MISSING(struct_, has_method))
return RV_CONTINUE;
CefBrowserCppToC* browserPtr = new CefBrowserCppToC(browser);
browserPtr->AddRef();
CefVariantCppToC* valuePtr = new CefVariantCppToC(value);
valuePtr->AddRef();
return struct_->get_property(struct_, browserPtr->GetStruct(), name.c_str(),
valuePtr->GetStruct());
}
bool CefJSHandlerCToCpp::ExecuteMethod(CefRefPtr<CefBrowser> browser,
const std::wstring& name,
const VariantVector& args,
CefRefPtr<CefVariant> retval)
{
if(CEF_MEMBER_MISSING(struct_, has_method))
return RV_CONTINUE;
CefBrowserCppToC* browserPtr = new CefBrowserCppToC(browser);
browserPtr->AddRef();
CefVariantCppToC* retvalPtr = new CefVariantCppToC(retval);
retvalPtr->AddRef();
cef_variant_t** argsStructPtr = NULL;
int argsSize = args.size();
if(argsSize > 0) {
CefVariantCppToC* vPtr;
argsStructPtr = new cef_variant_t*[argsSize];
for(int i = 0; i < argsSize; ++i) {
vPtr = new CefVariantCppToC(args[i]);
vPtr->AddRef();
argsStructPtr[i] = vPtr->GetStruct();
}
}
int rv = struct_->execute_method(struct_, browserPtr->GetStruct(),
name.c_str(), argsSize, argsStructPtr, retvalPtr->GetStruct());
if(argsStructPtr)
delete [] argsStructPtr;
return rv;
}