Replace JSBindingHandler with a new V8ContextHandler interface that contains callbacks for V8 context creation and release (issue #359).

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@392 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt
2011-11-21 21:21:55 +00:00
parent ead9b4508c
commit 605753c3b8
25 changed files with 335 additions and 195 deletions

View File

@@ -15,7 +15,6 @@
#include "libcef_dll/cpptoc/drag_handler_cpptoc.h"
#include "libcef_dll/cpptoc/find_handler_cpptoc.h"
#include "libcef_dll/cpptoc/focus_handler_cpptoc.h"
#include "libcef_dll/cpptoc/jsbinding_handler_cpptoc.h"
#include "libcef_dll/cpptoc/jsdialog_handler_cpptoc.h"
#include "libcef_dll/cpptoc/keyboard_handler_cpptoc.h"
#include "libcef_dll/cpptoc/life_span_handler_cpptoc.h"
@@ -24,6 +23,7 @@
#include "libcef_dll/cpptoc/print_handler_cpptoc.h"
#include "libcef_dll/cpptoc/render_handler_cpptoc.h"
#include "libcef_dll/cpptoc/request_handler_cpptoc.h"
#include "libcef_dll/cpptoc/v8context_handler_cpptoc.h"
// MEMBER FUNCTIONS - Body may be edited by hand.
@@ -178,17 +178,17 @@ cef_jsdialog_handler_t* CEF_CALLBACK client_get_jsdialog_handler(
return NULL;
}
cef_jsbinding_handler_t* CEF_CALLBACK client_get_jsbinding_handler(
cef_v8context_handler_t* CEF_CALLBACK client_get_v8context_handler(
struct _cef_client_t* self)
{
DCHECK(self);
if (!self)
return NULL;
CefRefPtr<CefJSBindingHandler> handlerPtr =
CefClientCppToC::Get(self)->GetJSBindingHandler();
CefRefPtr<CefV8ContextHandler> handlerPtr =
CefClientCppToC::Get(self)->GetV8ContextHandler();
if(handlerPtr.get())
return CefJSBindingHandlerCppToC::Wrap(handlerPtr);
return CefV8ContextHandlerCppToC::Wrap(handlerPtr);
return NULL;
}
@@ -239,7 +239,7 @@ CefClientCppToC::CefClientCppToC(CefClient* cls)
struct_.struct_.get_print_handler = client_get_print_handler;
struct_.struct_.get_find_handler = client_get_find_handler;
struct_.struct_.get_jsdialog_handler = client_get_jsdialog_handler;
struct_.struct_.get_jsbinding_handler = client_get_jsbinding_handler;
struct_.struct_.get_v8context_handler = client_get_v8context_handler;
struct_.struct_.get_render_handler = client_get_render_handler;
struct_.struct_.get_drag_handler = client_get_drag_handler;
}

View File

@@ -1,51 +0,0 @@
// Copyright (c) 2011 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 function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
#include "libcef_dll/cpptoc/jsbinding_handler_cpptoc.h"
#include "libcef_dll/ctocpp/browser_ctocpp.h"
#include "libcef_dll/ctocpp/frame_ctocpp.h"
#include "libcef_dll/ctocpp/v8value_ctocpp.h"
// MEMBER FUNCTIONS - Body may be edited by hand.
void CEF_CALLBACK jsbinding_handler_on_jsbinding(
struct _cef_jsbinding_handler_t* self, cef_browser_t* browser,
cef_frame_t* frame, struct _cef_v8value_t* object)
{
DCHECK(self);
DCHECK(browser);
DCHECK(frame);
DCHECK(object);
if (!self || !browser || !frame || !object)
return;
return CefJSBindingHandlerCppToC::Get(self)->OnJSBinding(
CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame),
CefV8ValueCToCpp::Wrap(object));
}
// CONSTRUCTOR - Do not edit by hand.
CefJSBindingHandlerCppToC::CefJSBindingHandlerCppToC(CefJSBindingHandler* cls)
: CefCppToC<CefJSBindingHandlerCppToC, CefJSBindingHandler,
cef_jsbinding_handler_t>(cls)
{
struct_.struct_.on_jsbinding = jsbinding_handler_on_jsbinding;
}
#ifndef NDEBUG
template<> long CefCppToC<CefJSBindingHandlerCppToC, CefJSBindingHandler,
cef_jsbinding_handler_t>::DebugObjCt = 0;
#endif

View File

@@ -104,6 +104,18 @@ int CEF_CALLBACK v8context_exit(struct _cef_v8context_t* self)
return contextPtr->Exit();
}
int CEF_CALLBACK v8context_is_same(struct _cef_v8context_t* self,
struct _cef_v8context_t* that)
{
DCHECK(self);
DCHECK(that);
if (!self || !that)
return false;
return CefV8ContextCppToC::Get(self)->IsSame(
CefV8ContextCppToC::Unwrap(that));
}
// CONSTRUCTOR - Do not edit by hand.
@@ -115,6 +127,7 @@ CefV8ContextCppToC::CefV8ContextCppToC(CefV8Context* cls)
struct_.struct_.get_global = v8context_get_global;
struct_.struct_.enter = v8context_enter;
struct_.struct_.exit = v8context_exit;
struct_.struct_.is_same = v8context_is_same;
}
#ifndef NDEBUG

View File

@@ -0,0 +1,68 @@
// Copyright (c) 2011 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 function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
#include "libcef_dll/cpptoc/v8context_handler_cpptoc.h"
#include "libcef_dll/ctocpp/browser_ctocpp.h"
#include "libcef_dll/ctocpp/frame_ctocpp.h"
#include "libcef_dll/ctocpp/v8context_ctocpp.h"
// MEMBER FUNCTIONS - Body may be edited by hand.
void CEF_CALLBACK v8context_handler_on_context_created(
struct _cef_v8context_handler_t* self, cef_browser_t* browser,
cef_frame_t* frame, struct _cef_v8context_t* context)
{
DCHECK(self);
DCHECK(browser);
DCHECK(frame);
DCHECK(context);
if (!self || !browser || !frame || !context)
return;
CefV8ContextHandlerCppToC::Get(self)->OnContextCreated(
CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame),
CefV8ContextCToCpp::Wrap(context));
}
void CEF_CALLBACK v8context_handler_on_context_released(
struct _cef_v8context_handler_t* self, cef_browser_t* browser,
cef_frame_t* frame, struct _cef_v8context_t* context)
{
DCHECK(self);
DCHECK(browser);
DCHECK(frame);
DCHECK(context);
if (!self || !browser || !frame || !context)
return;
CefV8ContextHandlerCppToC::Get(self)->OnContextReleased(
CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame),
CefV8ContextCToCpp::Wrap(context));
}
// CONSTRUCTOR - Do not edit by hand.
CefV8ContextHandlerCppToC::CefV8ContextHandlerCppToC(CefV8ContextHandler* cls)
: CefCppToC<CefV8ContextHandlerCppToC, CefV8ContextHandler,
cef_v8context_handler_t>(cls)
{
struct_.struct_.on_context_created = v8context_handler_on_context_created;
struct_.struct_.on_context_released = v8context_handler_on_context_released;
}
#ifndef NDEBUG
template<> long CefCppToC<CefV8ContextHandlerCppToC, CefV8ContextHandler,
cef_v8context_handler_t>::DebugObjCt = 0;
#endif

View File

@@ -8,8 +8,8 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
#ifndef _JSBINDINGHANDLER_CPPTOC_H
#define _JSBINDINGHANDLER_CPPTOC_H
#ifndef _V8CONTEXTHANDLER_CPPTOC_H
#define _V8CONTEXTHANDLER_CPPTOC_H
#ifndef USING_CEF_SHARED
#pragma message("Warning: "__FILE__" may be accessed wrapper-side only")
@@ -21,15 +21,15 @@
// Wrap a C++ class with a C structure.
// This class may be instantiated and accessed wrapper-side only.
class CefJSBindingHandlerCppToC
: public CefCppToC<CefJSBindingHandlerCppToC, CefJSBindingHandler,
cef_jsbinding_handler_t>
class CefV8ContextHandlerCppToC
: public CefCppToC<CefV8ContextHandlerCppToC, CefV8ContextHandler,
cef_v8context_handler_t>
{
public:
CefJSBindingHandlerCppToC(CefJSBindingHandler* cls);
virtual ~CefJSBindingHandlerCppToC() {}
CefV8ContextHandlerCppToC(CefV8ContextHandler* cls);
virtual ~CefV8ContextHandlerCppToC() {}
};
#endif // USING_CEF_SHARED
#endif // _JSBINDINGHANDLER_CPPTOC_H
#endif // _V8CONTEXTHANDLER_CPPTOC_H