- Add a CefV8Context object and CefV8Value::ExecuteFunctionWithContext method to support asynchronous V8 ExecuteFunction callbacks.
- Add a CefFrame::GetBrowser() method.
- Ensure that V8 types are only referenced on the UI thread.
- Accept a empty |object| parameter to CefV8Value::ExecuteFunction.

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@188 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt
2011-02-21 22:44:06 +00:00
parent 42846e6e31
commit 06a6f0ce7c
20 changed files with 1337 additions and 336 deletions

View File

@ -10,6 +10,7 @@
// tools directory for more information.
//
#include "libcef_dll/ctocpp/browser_ctocpp.h"
#include "libcef_dll/ctocpp/frame_ctocpp.h"
#include "libcef_dll/ctocpp/request_ctocpp.h"
#include "libcef_dll/ctocpp/stream_reader_ctocpp.h"
@ -193,6 +194,19 @@ CefString CefFrameCToCpp::GetURL()
return str;
}
CefRefPtr<CefBrowser> CefFrameCToCpp::GetBrowser()
{
CefRefPtr<CefBrowser> browser;
if(CEF_MEMBER_MISSING(struct_, get_browser))
return browser;
cef_browser_t* browserStruct = struct_->get_browser(struct_);
if(browserStruct)
return CefBrowserCToCpp::Wrap(browserStruct);
return browser;
}
#ifdef _DEBUG
template<> long CefCToCpp<CefFrameCToCpp, CefFrame, cef_frame_t>::DebugObjCt =

View File

@ -53,6 +53,7 @@ public:
virtual bool IsFocused();
virtual CefString GetName();
virtual CefString GetURL();
virtual CefRefPtr<CefBrowser> GetBrowser();
};
#endif // USING_CEF_SHARED

View File

@ -0,0 +1,81 @@
// Copyright (c) 2010 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.
//
// ---------------------------------------------------------------------------
//
// A portion of this file was generated by the CEF translator tool. When
// making changes by hand only do so within the body of existing static and
// virtual method implementations. See the translator.README.txt file in the
// tools directory for more information.
//
#include "libcef_dll/ctocpp/browser_ctocpp.h"
#include "libcef_dll/ctocpp/frame_ctocpp.h"
#include "libcef_dll/ctocpp/v8context_ctocpp.h"
#include "libcef_dll/ctocpp/v8value_ctocpp.h"
// STATIC METHODS - Body may be edited by hand.
CefRefPtr<CefV8Context> CefV8Context::GetCurrentContext()
{
cef_v8context_t* impl = cef_v8context_get_current_context();
if(impl)
return CefV8ContextCToCpp::Wrap(impl);
return NULL;
}
CefRefPtr<CefV8Context> CefV8Context::GetEnteredContext()
{
cef_v8context_t* impl = cef_v8context_get_entered_context();
if(impl)
return CefV8ContextCToCpp::Wrap(impl);
return NULL;
}
// VIRTUAL METHODS - Body may be edited by hand.
CefRefPtr<CefBrowser> CefV8ContextCToCpp::GetBrowser()
{
if(CEF_MEMBER_MISSING(struct_, get_browser))
return NULL;
cef_browser_t* browserStruct = struct_->get_browser(struct_);
if(browserStruct)
return CefBrowserCToCpp::Wrap(browserStruct);
return NULL;
}
CefRefPtr<CefFrame> CefV8ContextCToCpp::GetFrame()
{
if(CEF_MEMBER_MISSING(struct_, get_frame))
return NULL;
cef_frame_t* frameStruct = struct_->get_frame(struct_);
if(frameStruct)
return CefFrameCToCpp::Wrap(frameStruct);
return NULL;
}
CefRefPtr<CefV8Value> CefV8ContextCToCpp::GetGlobal()
{
if(CEF_MEMBER_MISSING(struct_, get_global))
return NULL;
cef_v8value_t* v8valueStruct = struct_->get_global(struct_);
if(v8valueStruct)
return CefV8ValueCToCpp::Wrap(v8valueStruct);
return NULL;
}
#ifdef _DEBUG
template<> long CefCToCpp<CefV8ContextCToCpp, CefV8Context,
cef_v8context_t>::DebugObjCt = 0;
#endif

View File

@ -0,0 +1,41 @@
// Copyright (c) 2010 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.
//
// -------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
#ifndef _V8CONTEXT_CTOCPP_H
#define _V8CONTEXT_CTOCPP_H
#ifndef USING_CEF_SHARED
#pragma message("Warning: "__FILE__" may be accessed wrapper-side only")
#else // USING_CEF_SHARED
#include "include/cef.h"
#include "include/cef_capi.h"
#include "libcef_dll/ctocpp/ctocpp.h"
// Wrap a C structure with a C++ class.
// This class may be instantiated and accessed wrapper-side only.
class CefV8ContextCToCpp
: public CefCToCpp<CefV8ContextCToCpp, CefV8Context, cef_v8context_t>
{
public:
CefV8ContextCToCpp(cef_v8context_t* str)
: CefCToCpp<CefV8ContextCToCpp, CefV8Context, cef_v8context_t>(str) {}
virtual ~CefV8ContextCToCpp() {}
// CefV8Context methods
virtual CefRefPtr<CefBrowser> GetBrowser();
virtual CefRefPtr<CefFrame> GetFrame();
virtual CefRefPtr<CefV8Value> GetGlobal();
};
#endif // USING_CEF_SHARED
#endif // _V8CONTEXT_CTOCPP_H

View File

@ -12,6 +12,7 @@
#include "libcef_dll/cpptoc/base_cpptoc.h"
#include "libcef_dll/cpptoc/v8handler_cpptoc.h"
#include "libcef_dll/ctocpp/v8context_ctocpp.h"
#include "libcef_dll/ctocpp/v8value_ctocpp.h"
#include "libcef_dll/transfer_util.h"
@ -344,7 +345,7 @@ bool CefV8ValueCToCpp::ExecuteFunction(CefRefPtr<CefV8Value> object,
CefString& exception)
{
if(CEF_MEMBER_MISSING(struct_, execute_function))
return RV_CONTINUE;
return false;
cef_v8value_t** argsStructPtr = NULL;
int argsSize = arguments.size();
@ -356,7 +357,8 @@ bool CefV8ValueCToCpp::ExecuteFunction(CefRefPtr<CefV8Value> object,
cef_v8value_t* retvalStruct = NULL;
int rv = struct_->execute_function(struct_, CefV8ValueCToCpp::Unwrap(object),
int rv = struct_->execute_function(struct_,
object.get() ? CefV8ValueCToCpp::Unwrap(object): NULL,
argsSize, argsStructPtr, &retvalStruct, exception.GetWritableStruct());
if(retvalStruct)
retval = CefV8ValueCToCpp::Wrap(retvalStruct);
@ -367,6 +369,38 @@ bool CefV8ValueCToCpp::ExecuteFunction(CefRefPtr<CefV8Value> object,
return rv?true:false;
}
bool CefV8ValueCToCpp::ExecuteFunctionWithContext(
CefRefPtr<CefV8Context> context, CefRefPtr<CefV8Value> object,
const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval,
CefString& exception)
{
if(CEF_MEMBER_MISSING(struct_, execute_function_with_context))
return false;
cef_v8value_t** argsStructPtr = NULL;
int argsSize = arguments.size();
if(argsSize > 0) {
argsStructPtr = new cef_v8value_t*[argsSize];
for(int i = 0; i < argsSize; ++i)
argsStructPtr[i] = CefV8ValueCToCpp::Unwrap(arguments[i]);
}
cef_v8value_t* retvalStruct = NULL;
int rv = struct_->execute_function_with_context(struct_,
context.get() ? CefV8ContextCToCpp::Unwrap(context): NULL,
object.get() ? CefV8ValueCToCpp::Unwrap(object): NULL,
argsSize, argsStructPtr, &retvalStruct, exception.GetWritableStruct());
if(retvalStruct)
retval = CefV8ValueCToCpp::Wrap(retvalStruct);
if(argsStructPtr)
delete [] argsStructPtr;
return rv?true:false;
}
#ifdef _DEBUG
template<> long CefCToCpp<CefV8ValueCToCpp, CefV8Value,

View File

@ -60,6 +60,9 @@ public:
virtual bool ExecuteFunction(CefRefPtr<CefV8Value> object,
const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval,
CefString& exception);
virtual bool ExecuteFunctionWithContext(CefRefPtr<CefV8Context> context,
CefRefPtr<CefV8Value> object, const CefV8ValueList& arguments,
CefRefPtr<CefV8Value>& retval, CefString& exception);
};
#endif // USING_CEF_SHARED