mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
- 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
This commit is contained in:
@@ -1,163 +0,0 @@
|
||||
// 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 "cef_string.h"
|
||||
#include <limits.h>
|
||||
#include <malloc.h>
|
||||
#include <string.h>
|
||||
|
||||
typedef unsigned long dword_t;
|
||||
|
||||
CEF_EXPORT size_t cef_string_length(cef_string_t str)
|
||||
{
|
||||
dword_t* ptr;
|
||||
|
||||
if(!str)
|
||||
return 0;
|
||||
|
||||
// The string length, in bytes, is placed in a dword_t immediately proceeding
|
||||
// the string value.
|
||||
ptr = (dword_t*)str;
|
||||
ptr--;
|
||||
|
||||
return (size_t)(*ptr / sizeof(wchar_t));
|
||||
}
|
||||
|
||||
CEF_EXPORT cef_string_t cef_string_alloc(const wchar_t* str)
|
||||
{
|
||||
if(!str)
|
||||
return NULL;
|
||||
|
||||
return cef_string_alloc_length(str, wcslen(str));
|
||||
}
|
||||
|
||||
CEF_EXPORT cef_string_t cef_string_alloc_length(const wchar_t* str,
|
||||
size_t len)
|
||||
{
|
||||
dword_t size, *ptr;
|
||||
wchar_t* newstr;
|
||||
|
||||
// Check that the size can fit in a dword_t.
|
||||
if(len >= (UINT_MAX - sizeof(wchar_t) - sizeof(dword_t)) / sizeof(wchar_t))
|
||||
return NULL;
|
||||
|
||||
// Get the size of the string in bytes.
|
||||
size = sizeof(wchar_t) * len;
|
||||
|
||||
// Allocate the new buffer including space for the proceeding dword_t size
|
||||
// value and the terminating nul.
|
||||
ptr = (dword_t*)malloc(sizeof(dword_t) + size + sizeof(wchar_t));
|
||||
if(!ptr)
|
||||
return NULL;
|
||||
|
||||
// Set the size as the first value in the newly allocated memory and
|
||||
// increment to the string location.
|
||||
*ptr = size;
|
||||
ptr++;
|
||||
|
||||
if(str != NULL)
|
||||
{
|
||||
// Copy the string to the buffer.
|
||||
memcpy(ptr, str, size);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Initialize the string to zeros.
|
||||
memset(ptr, 0, size);
|
||||
}
|
||||
|
||||
newstr = (wchar_t*)ptr;
|
||||
|
||||
// Nul-terminate the string.
|
||||
newstr[len] = '\0';
|
||||
|
||||
return (cef_string_t)newstr;
|
||||
}
|
||||
|
||||
CEF_EXPORT int cef_string_realloc(cef_string_t* oldstr, const wchar_t* newstr)
|
||||
{
|
||||
if(!oldstr)
|
||||
return 0;
|
||||
|
||||
// Free the old string.
|
||||
cef_string_free(*oldstr);
|
||||
|
||||
// Copy the new string.
|
||||
*oldstr = cef_string_alloc(newstr);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
CEF_EXPORT int cef_string_realloc_length(cef_string_t* oldstr,
|
||||
const wchar_t* newstr,
|
||||
size_t len)
|
||||
{
|
||||
if(!oldstr)
|
||||
return 0;
|
||||
|
||||
// Check that the size can fit in a dword_t.
|
||||
if(len >= (UINT_MAX - sizeof(wchar_t) - sizeof(dword_t)) / sizeof(wchar_t))
|
||||
return 0;
|
||||
|
||||
if(*oldstr)
|
||||
{
|
||||
dword_t newsize, *oldptr, *newptr;
|
||||
|
||||
// Get the new size of the string in bytes.
|
||||
newsize = sizeof(wchar_t) * len;
|
||||
|
||||
// Adjust the pointer to account for the dword_t immediately proceeding the
|
||||
// string value.
|
||||
oldptr = (dword_t*)*oldstr;
|
||||
oldptr--;
|
||||
|
||||
// Re-allocate the buffer including space for the proceeding dword_t size
|
||||
// value and the terminating nul.
|
||||
newptr = (dword_t*)realloc(
|
||||
oldptr, sizeof(dword_t) + newsize + sizeof(wchar_t));
|
||||
if(!newptr)
|
||||
return 0;
|
||||
|
||||
// Set the size as the first value in the newly allocated memory and
|
||||
// increment to the string location.
|
||||
*newptr = newsize;
|
||||
newptr++;
|
||||
|
||||
// Set the string pointer to the beginning on the string in the newly
|
||||
// allocated memory.
|
||||
*oldstr = (cef_string_t)newptr;
|
||||
|
||||
if(newstr)
|
||||
{
|
||||
// Copy the new string value. Use of memmove() ensures that any
|
||||
// overlapping region in the old string will be copied before being
|
||||
// overwritten.
|
||||
memmove(*oldstr, newstr, newsize);
|
||||
|
||||
// Nul-terminate the string.
|
||||
*oldstr[len] = '\0';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Allocate the string.
|
||||
*oldstr = cef_string_alloc_length(newstr, len);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
CEF_EXPORT void cef_string_free(cef_string_t str)
|
||||
{
|
||||
dword_t* ptr;
|
||||
|
||||
if(!str)
|
||||
return;
|
||||
|
||||
// The size is placed in a dword_t immediately proceeding the string value.
|
||||
ptr = (dword_t*)str;
|
||||
ptr--;
|
||||
|
||||
free(ptr);
|
||||
}
|
@@ -1,93 +0,0 @@
|
||||
// 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 "cef_logging.h"
|
||||
#include "cef_string_map.h"
|
||||
#include <map>
|
||||
|
||||
|
||||
typedef std::map<std::wstring, std::wstring> StringMap;
|
||||
|
||||
CEF_EXPORT cef_string_map_t cef_string_map_alloc()
|
||||
{
|
||||
return new StringMap;
|
||||
}
|
||||
|
||||
CEF_EXPORT int cef_string_map_size(cef_string_map_t map)
|
||||
{
|
||||
DCHECK(map);
|
||||
StringMap* impl = (StringMap*)map;
|
||||
return impl->size();
|
||||
}
|
||||
|
||||
CEF_EXPORT cef_string_t cef_string_map_find(cef_string_map_t map,
|
||||
const wchar_t* key)
|
||||
{
|
||||
DCHECK(map);
|
||||
StringMap* impl = (StringMap*)map;
|
||||
std::wstring keystr;
|
||||
if(key)
|
||||
keystr = key;
|
||||
StringMap::const_iterator it = impl->find(keystr);
|
||||
if(it == impl->end())
|
||||
return NULL;
|
||||
return cef_string_alloc(it->second.c_str());
|
||||
}
|
||||
|
||||
CEF_EXPORT cef_string_t cef_string_map_key(cef_string_map_t map, int index)
|
||||
{
|
||||
DCHECK(map);
|
||||
StringMap* impl = (StringMap*)map;
|
||||
DCHECK(index >= 0 && index < (int)impl->size());
|
||||
if(index < 0 || index >= (int)impl->size())
|
||||
return NULL;
|
||||
StringMap::const_iterator it = impl->begin();
|
||||
for(int ct = 0; it != impl->end(); ++it, ct++) {
|
||||
if(ct == index)
|
||||
return cef_string_alloc(it->first.c_str());
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CEF_EXPORT cef_string_t cef_string_map_value(cef_string_map_t map, int index)
|
||||
{
|
||||
DCHECK(map);
|
||||
StringMap* impl = (StringMap*)map;
|
||||
DCHECK(index >= 0 && index < (int)impl->size());
|
||||
if(index < 0 || index >= (int)impl->size())
|
||||
return NULL;
|
||||
StringMap::const_iterator it = impl->begin();
|
||||
for(int ct = 0; it != impl->end(); ++it, ct++) {
|
||||
if(ct == index)
|
||||
return cef_string_alloc(it->second.c_str());
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CEF_EXPORT void cef_string_map_append(cef_string_map_t map, const wchar_t* key,
|
||||
const wchar_t* value)
|
||||
{
|
||||
DCHECK(map);
|
||||
StringMap* impl = (StringMap*)map;
|
||||
std::wstring keystr, valstr;
|
||||
if(key)
|
||||
keystr = key;
|
||||
if(value)
|
||||
valstr = value;
|
||||
impl->insert(std::pair<std::wstring, std::wstring>(keystr, valstr));
|
||||
}
|
||||
|
||||
CEF_EXPORT void cef_string_map_clear(cef_string_map_t map)
|
||||
{
|
||||
DCHECK(map);
|
||||
StringMap* impl = (StringMap*)map;
|
||||
impl->clear();
|
||||
}
|
||||
|
||||
CEF_EXPORT void cef_string_map_free(cef_string_map_t map)
|
||||
{
|
||||
DCHECK(map);
|
||||
delete (StringMap*)map;
|
||||
}
|
@@ -4,10 +4,8 @@
|
||||
|
||||
#include "../precompiled_libcef.h"
|
||||
#include "cpptoc/browser_cpptoc.h"
|
||||
#include "cpptoc/request_cpptoc.h"
|
||||
#include "cpptoc/stream_cpptoc.h"
|
||||
#include "cpptoc/frame_cpptoc.h"
|
||||
#include "ctocpp/handler_ctocpp.h"
|
||||
#include "ctocpp/jshandler_ctocpp.h"
|
||||
|
||||
|
||||
int CEF_CALLBACK browser_can_go_back(cef_browser_t* browser)
|
||||
@@ -16,9 +14,7 @@ int CEF_CALLBACK browser_can_go_back(cef_browser_t* browser)
|
||||
if(!browser)
|
||||
return 0;
|
||||
|
||||
CefBrowserCppToC::Struct* impl =
|
||||
reinterpret_cast<CefBrowserCppToC::Struct*>(browser);
|
||||
return impl->class_->GetClass()->CanGoBack();
|
||||
return CefBrowserCppToC::Get(browser)->CanGoBack();
|
||||
}
|
||||
|
||||
void CEF_CALLBACK browser_go_back(cef_browser_t* browser)
|
||||
@@ -27,9 +23,7 @@ void CEF_CALLBACK browser_go_back(cef_browser_t* browser)
|
||||
if(!browser)
|
||||
return;
|
||||
|
||||
CefBrowserCppToC::Struct* impl =
|
||||
reinterpret_cast<CefBrowserCppToC::Struct*>(browser);
|
||||
impl->class_->GetClass()->GoBack();
|
||||
CefBrowserCppToC::Get(browser)->GoBack();
|
||||
}
|
||||
|
||||
int CEF_CALLBACK browser_can_go_forward(cef_browser_t* browser)
|
||||
@@ -38,9 +32,7 @@ int CEF_CALLBACK browser_can_go_forward(cef_browser_t* browser)
|
||||
if(!browser)
|
||||
return 0;
|
||||
|
||||
CefBrowserCppToC::Struct* impl =
|
||||
reinterpret_cast<CefBrowserCppToC::Struct*>(browser);
|
||||
return impl->class_->GetClass()->CanGoForward();
|
||||
return CefBrowserCppToC::Get(browser)->CanGoForward();
|
||||
}
|
||||
|
||||
void CEF_CALLBACK browser_go_forward(cef_browser_t* browser)
|
||||
@@ -49,9 +41,7 @@ void CEF_CALLBACK browser_go_forward(cef_browser_t* browser)
|
||||
if(!browser)
|
||||
return;
|
||||
|
||||
CefBrowserCppToC::Struct* impl =
|
||||
reinterpret_cast<CefBrowserCppToC::Struct*>(browser);
|
||||
impl->class_->GetClass()->GoForward();
|
||||
CefBrowserCppToC::Get(browser)->GoForward();
|
||||
}
|
||||
|
||||
void CEF_CALLBACK browser_reload(cef_browser_t* browser)
|
||||
@@ -60,9 +50,7 @@ void CEF_CALLBACK browser_reload(cef_browser_t* browser)
|
||||
if(!browser)
|
||||
return;
|
||||
|
||||
CefBrowserCppToC::Struct* impl =
|
||||
reinterpret_cast<CefBrowserCppToC::Struct*>(browser);
|
||||
impl->class_->GetClass()->Reload();
|
||||
CefBrowserCppToC::Get(browser)->Reload();
|
||||
}
|
||||
|
||||
void CEF_CALLBACK browser_stop_load(cef_browser_t* browser)
|
||||
@@ -71,93 +59,7 @@ void CEF_CALLBACK browser_stop_load(cef_browser_t* browser)
|
||||
if(!browser)
|
||||
return;
|
||||
|
||||
CefBrowserCppToC::Struct* impl =
|
||||
reinterpret_cast<CefBrowserCppToC::Struct*>(browser);
|
||||
impl->class_->GetClass()->StopLoad();
|
||||
}
|
||||
|
||||
void CEF_CALLBACK browser_undo(cef_browser_t* browser,
|
||||
enum cef_targetframe_t targetFrame)
|
||||
{
|
||||
DCHECK(browser);
|
||||
if(!browser)
|
||||
return;
|
||||
|
||||
CefBrowserCppToC::Struct* impl =
|
||||
reinterpret_cast<CefBrowserCppToC::Struct*>(browser);
|
||||
impl->class_->GetClass()->Undo(targetFrame);
|
||||
}
|
||||
|
||||
void CEF_CALLBACK browser_redo(cef_browser_t* browser,
|
||||
enum cef_targetframe_t targetFrame)
|
||||
{
|
||||
DCHECK(browser);
|
||||
if(!browser)
|
||||
return;
|
||||
|
||||
CefBrowserCppToC::Struct* impl =
|
||||
reinterpret_cast<CefBrowserCppToC::Struct*>(browser);
|
||||
impl->class_->GetClass()->Redo(targetFrame);
|
||||
}
|
||||
|
||||
void CEF_CALLBACK browser_cut(cef_browser_t* browser,
|
||||
enum cef_targetframe_t targetFrame)
|
||||
{
|
||||
DCHECK(browser);
|
||||
if(!browser)
|
||||
return;
|
||||
|
||||
CefBrowserCppToC::Struct* impl =
|
||||
reinterpret_cast<CefBrowserCppToC::Struct*>(browser);
|
||||
impl->class_->GetClass()->Cut(targetFrame);
|
||||
}
|
||||
|
||||
void CEF_CALLBACK browser_copy(cef_browser_t* browser,
|
||||
enum cef_targetframe_t targetFrame)
|
||||
{
|
||||
DCHECK(browser);
|
||||
if(!browser)
|
||||
return;
|
||||
|
||||
CefBrowserCppToC::Struct* impl =
|
||||
reinterpret_cast<CefBrowserCppToC::Struct*>(browser);
|
||||
impl->class_->GetClass()->Copy(targetFrame);
|
||||
}
|
||||
|
||||
void CEF_CALLBACK browser_paste(cef_browser_t* browser,
|
||||
enum cef_targetframe_t targetFrame)
|
||||
{
|
||||
DCHECK(browser);
|
||||
if(!browser)
|
||||
return;
|
||||
|
||||
CefBrowserCppToC::Struct* impl =
|
||||
reinterpret_cast<CefBrowserCppToC::Struct*>(browser);
|
||||
impl->class_->GetClass()->Paste(targetFrame);
|
||||
}
|
||||
|
||||
void CEF_CALLBACK browser_delete(cef_browser_t* browser,
|
||||
enum cef_targetframe_t targetFrame)
|
||||
{
|
||||
DCHECK(browser);
|
||||
if(!browser)
|
||||
return;
|
||||
|
||||
CefBrowserCppToC::Struct* impl =
|
||||
reinterpret_cast<CefBrowserCppToC::Struct*>(browser);
|
||||
impl->class_->GetClass()->Delete(targetFrame);
|
||||
}
|
||||
|
||||
void CEF_CALLBACK browser_select_all(cef_browser_t* browser,
|
||||
enum cef_targetframe_t targetFrame)
|
||||
{
|
||||
DCHECK(browser);
|
||||
if(!browser)
|
||||
return;
|
||||
|
||||
CefBrowserCppToC::Struct* impl =
|
||||
reinterpret_cast<CefBrowserCppToC::Struct*>(browser);
|
||||
impl->class_->GetClass()->SelectAll(targetFrame);
|
||||
CefBrowserCppToC::Get(browser)->StopLoad();
|
||||
}
|
||||
|
||||
void CEF_CALLBACK browser_set_focus(struct _cef_browser_t* browser, int enable)
|
||||
@@ -166,254 +68,7 @@ void CEF_CALLBACK browser_set_focus(struct _cef_browser_t* browser, int enable)
|
||||
if(!browser)
|
||||
return;
|
||||
|
||||
CefBrowserCppToC::Struct* impl =
|
||||
reinterpret_cast<CefBrowserCppToC::Struct*>(browser);
|
||||
impl->class_->GetClass()->SetFocus(enable ? true : false);
|
||||
}
|
||||
|
||||
void CEF_CALLBACK browser_print(cef_browser_t* browser,
|
||||
enum cef_targetframe_t targetFrame)
|
||||
{
|
||||
DCHECK(browser);
|
||||
if(!browser)
|
||||
return;
|
||||
|
||||
CefBrowserCppToC::Struct* impl =
|
||||
reinterpret_cast<CefBrowserCppToC::Struct*>(browser);
|
||||
impl->class_->GetClass()->Print(targetFrame);
|
||||
}
|
||||
|
||||
void CEF_CALLBACK browser_view_source(cef_browser_t* browser,
|
||||
enum cef_targetframe_t targetFrame)
|
||||
{
|
||||
DCHECK(browser);
|
||||
if(!browser)
|
||||
return;
|
||||
|
||||
CefBrowserCppToC::Struct* impl =
|
||||
reinterpret_cast<CefBrowserCppToC::Struct*>(browser);
|
||||
impl->class_->GetClass()->ViewSource(targetFrame);
|
||||
}
|
||||
|
||||
cef_string_t CEF_CALLBACK browser_get_source(cef_browser_t* browser,
|
||||
enum cef_targetframe_t targetFrame)
|
||||
{
|
||||
DCHECK(browser);
|
||||
if(!browser)
|
||||
return NULL;
|
||||
|
||||
CefBrowserCppToC::Struct* impl =
|
||||
reinterpret_cast<CefBrowserCppToC::Struct*>(browser);
|
||||
|
||||
std::wstring sourceStr = impl->class_->GetClass()->GetSource(targetFrame);
|
||||
if(sourceStr.empty())
|
||||
return NULL;
|
||||
return cef_string_alloc(sourceStr.c_str());
|
||||
}
|
||||
|
||||
cef_string_t CEF_CALLBACK browser_get_text(cef_browser_t* browser,
|
||||
enum cef_targetframe_t targetFrame)
|
||||
{
|
||||
DCHECK(browser);
|
||||
if(!browser)
|
||||
return NULL;
|
||||
|
||||
CefBrowserCppToC::Struct* impl =
|
||||
reinterpret_cast<CefBrowserCppToC::Struct*>(browser);
|
||||
|
||||
std::wstring textStr = impl->class_->GetClass()->GetText(targetFrame);
|
||||
if(textStr.empty())
|
||||
return NULL;
|
||||
return cef_string_alloc(textStr.c_str());
|
||||
}
|
||||
|
||||
void CEF_CALLBACK browser_load_request(cef_browser_t* browser,
|
||||
cef_request_t* request)
|
||||
{
|
||||
DCHECK(browser);
|
||||
DCHECK(request);
|
||||
if(!browser || !request)
|
||||
return;
|
||||
|
||||
CefBrowserCppToC::Struct* impl =
|
||||
reinterpret_cast<CefBrowserCppToC::Struct*>(browser);
|
||||
|
||||
CefRequestCppToC::Struct* structPtr =
|
||||
reinterpret_cast<CefRequestCppToC::Struct*>(request);
|
||||
CefRefPtr<CefRequest> requestPtr(structPtr->class_->GetClass());
|
||||
structPtr->class_->Release();
|
||||
impl->class_->GetClass()->LoadRequest(requestPtr);
|
||||
}
|
||||
|
||||
void CEF_CALLBACK browser_load_url(cef_browser_t* browser, const wchar_t* url,
|
||||
const wchar_t* frame)
|
||||
{
|
||||
DCHECK(browser);
|
||||
if(!browser)
|
||||
return;
|
||||
|
||||
CefBrowserCppToC::Struct* impl =
|
||||
reinterpret_cast<CefBrowserCppToC::Struct*>(browser);
|
||||
|
||||
std::wstring urlStr, frameStr;
|
||||
if(url)
|
||||
urlStr = url;
|
||||
if(frame)
|
||||
frameStr = frame;
|
||||
impl->class_->GetClass()->LoadURL(urlStr, frameStr);
|
||||
}
|
||||
|
||||
void CEF_CALLBACK browser_load_string(cef_browser_t* browser,
|
||||
const wchar_t* string,
|
||||
const wchar_t* url)
|
||||
{
|
||||
DCHECK(browser);
|
||||
if(!browser)
|
||||
return;
|
||||
|
||||
CefBrowserCppToC::Struct* impl =
|
||||
reinterpret_cast<CefBrowserCppToC::Struct*>(browser);
|
||||
|
||||
std::wstring stringStr, urlStr;
|
||||
if(string)
|
||||
stringStr = string;
|
||||
if(url)
|
||||
urlStr = url;
|
||||
impl->class_->GetClass()->LoadString(stringStr, urlStr);
|
||||
}
|
||||
|
||||
void CEF_CALLBACK browser_load_stream(cef_browser_t* browser,
|
||||
cef_stream_reader_t* stream,
|
||||
const wchar_t* url)
|
||||
{
|
||||
DCHECK(browser);
|
||||
DCHECK(stream);
|
||||
if(!browser || !stream)
|
||||
return;
|
||||
|
||||
CefBrowserCppToC::Struct* impl =
|
||||
reinterpret_cast<CefBrowserCppToC::Struct*>(browser);
|
||||
|
||||
CefStreamReaderCppToC::Struct* structPtr =
|
||||
reinterpret_cast<CefStreamReaderCppToC::Struct*>(stream);
|
||||
CefRefPtr<CefStreamReader> streamPtr(structPtr->class_->GetClass());
|
||||
structPtr->class_->Release();
|
||||
|
||||
std::wstring urlStr;
|
||||
if(url)
|
||||
urlStr = url;
|
||||
impl->class_->GetClass()->LoadStream(streamPtr, urlStr);
|
||||
}
|
||||
|
||||
void CEF_CALLBACK browser_execute_javascript(cef_browser_t* browser,
|
||||
const wchar_t* jsCode,
|
||||
const wchar_t* scriptUrl,
|
||||
int startLine,
|
||||
enum cef_targetframe_t targetFrame)
|
||||
{
|
||||
DCHECK(browser);
|
||||
if(!browser)
|
||||
return;
|
||||
|
||||
CefBrowserCppToC::Struct* impl =
|
||||
reinterpret_cast<CefBrowserCppToC::Struct*>(browser);
|
||||
|
||||
std::wstring jsCodeStr, scriptUrlStr;
|
||||
if(jsCode)
|
||||
jsCodeStr = jsCode;
|
||||
if(scriptUrl)
|
||||
scriptUrlStr = scriptUrl;
|
||||
|
||||
impl->class_->GetClass()->ExecuteJavaScript(jsCodeStr, scriptUrlStr,
|
||||
startLine, targetFrame);
|
||||
}
|
||||
|
||||
int CEF_CALLBACK browser_add_jshandler(cef_browser_t* browser,
|
||||
const wchar_t* classname,
|
||||
cef_jshandler_t* handler)
|
||||
{
|
||||
DCHECK(browser);
|
||||
DCHECK(handler);
|
||||
if(!browser || !handler)
|
||||
return 0;
|
||||
|
||||
CefBrowserCppToC::Struct* impl =
|
||||
reinterpret_cast<CefBrowserCppToC::Struct*>(browser);
|
||||
|
||||
CefJSHandlerCToCpp* hp = new CefJSHandlerCToCpp(handler);
|
||||
CefRefPtr<CefJSHandler> handlerPtr(hp);
|
||||
hp->UnderlyingRelease();
|
||||
|
||||
std::wstring classnameStr;
|
||||
if(classname)
|
||||
classnameStr = classname;
|
||||
return impl->class_->GetClass()->AddJSHandler(classnameStr, handlerPtr);
|
||||
}
|
||||
|
||||
int CEF_CALLBACK browser_has_jshandler(cef_browser_t* browser,
|
||||
const wchar_t* classname)
|
||||
{
|
||||
DCHECK(browser);
|
||||
if(!browser)
|
||||
return 0;
|
||||
|
||||
CefBrowserCppToC::Struct* impl =
|
||||
reinterpret_cast<CefBrowserCppToC::Struct*>(browser);
|
||||
|
||||
std::wstring classnameStr;
|
||||
if(classname)
|
||||
classnameStr = classname;
|
||||
return impl->class_->GetClass()->HasJSHandler(classnameStr);
|
||||
}
|
||||
|
||||
cef_jshandler_t* CEF_CALLBACK browser_get_jshandler(cef_browser_t* browser,
|
||||
const wchar_t* classname)
|
||||
{
|
||||
DCHECK(browser);
|
||||
if(!browser)
|
||||
return NULL;
|
||||
|
||||
CefBrowserCppToC::Struct* impl =
|
||||
reinterpret_cast<CefBrowserCppToC::Struct*>(browser);
|
||||
|
||||
std::wstring classnameStr;
|
||||
if(classname)
|
||||
classnameStr = classname;
|
||||
CefRefPtr<CefJSHandler> handler =
|
||||
impl->class_->GetClass()->GetJSHandler(classnameStr);
|
||||
if(handler.get()) {
|
||||
CefJSHandlerCToCpp* hp = static_cast<CefJSHandlerCToCpp*>(handler.get());
|
||||
hp->UnderlyingAddRef();
|
||||
return hp->GetStruct();
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int CEF_CALLBACK browser_remove_jshandler(cef_browser_t* browser,
|
||||
const wchar_t* classname)
|
||||
{
|
||||
DCHECK(browser);
|
||||
if(!browser)
|
||||
return 0;
|
||||
|
||||
CefBrowserCppToC::Struct* impl =
|
||||
reinterpret_cast<CefBrowserCppToC::Struct*>(browser);
|
||||
|
||||
std::wstring classnameStr;
|
||||
if(classname)
|
||||
classnameStr = classname;
|
||||
return impl->class_->GetClass()->RemoveJSHandler(classnameStr);
|
||||
}
|
||||
|
||||
void CEF_CALLBACK browser_remove_all_jshandlers(cef_browser_t* browser)
|
||||
{
|
||||
DCHECK(browser);
|
||||
if(!browser)
|
||||
return;
|
||||
|
||||
CefBrowserCppToC::Struct* impl =
|
||||
reinterpret_cast<CefBrowserCppToC::Struct*>(browser);
|
||||
return impl->class_->GetClass()->RemoveAllJSHandlers();
|
||||
CefBrowserCppToC::Get(browser)->SetFocus(enable ? true : false);
|
||||
}
|
||||
|
||||
cef_window_handle_t CEF_CALLBACK browser_get_window_handle(cef_browser_t* browser)
|
||||
@@ -422,9 +77,7 @@ cef_window_handle_t CEF_CALLBACK browser_get_window_handle(cef_browser_t* browse
|
||||
if(!browser)
|
||||
return NULL;
|
||||
|
||||
CefBrowserCppToC::Struct* impl =
|
||||
reinterpret_cast<CefBrowserCppToC::Struct*>(browser);
|
||||
return impl->class_->GetClass()->GetWindowHandle();
|
||||
return CefBrowserCppToC::Get(browser)->GetWindowHandle();
|
||||
}
|
||||
|
||||
int CEF_CALLBACK browser_is_popup(cef_browser_t* browser)
|
||||
@@ -433,9 +86,7 @@ int CEF_CALLBACK browser_is_popup(cef_browser_t* browser)
|
||||
if(!browser)
|
||||
return 0;
|
||||
|
||||
CefBrowserCppToC::Struct* impl =
|
||||
reinterpret_cast<CefBrowserCppToC::Struct*>(browser);
|
||||
return impl->class_->GetClass()->IsPopup();
|
||||
return CefBrowserCppToC::Get(browser)->IsPopup();
|
||||
}
|
||||
|
||||
cef_handler_t* CEF_CALLBACK browser_get_handler(cef_browser_t* browser)
|
||||
@@ -444,35 +95,81 @@ cef_handler_t* CEF_CALLBACK browser_get_handler(cef_browser_t* browser)
|
||||
if(!browser)
|
||||
return NULL;
|
||||
|
||||
CefBrowserCppToC::Struct* impl =
|
||||
reinterpret_cast<CefBrowserCppToC::Struct*>(browser);
|
||||
|
||||
CefRefPtr<CefHandler> handler = impl->class_->GetClass()->GetHandler();
|
||||
if(handler.get()) {
|
||||
CefHandlerCToCpp* hp = static_cast<CefHandlerCToCpp*>(handler.get());
|
||||
hp->UnderlyingAddRef();
|
||||
return hp->GetStruct();
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
CefRefPtr<CefBrowser> browserPtr = CefBrowserCppToC::Get(browser);
|
||||
CefRefPtr<CefHandler> handlerPtr = browserPtr->GetHandler();
|
||||
if(handlerPtr.get())
|
||||
return CefHandlerCToCpp::Unwrap(handlerPtr);
|
||||
|
||||
cef_string_t CEF_CALLBACK browser_get_url(cef_browser_t* browser)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct _cef_frame_t* CEF_CALLBACK browser_get_main_frame(
|
||||
struct _cef_browser_t* browser)
|
||||
{
|
||||
DCHECK(browser);
|
||||
if(!browser)
|
||||
return NULL;
|
||||
|
||||
CefBrowserCppToC::Struct* impl =
|
||||
reinterpret_cast<CefBrowserCppToC::Struct*>(browser);
|
||||
|
||||
std::wstring urlStr = impl->class_->GetClass()->GetURL();
|
||||
if(urlStr.empty())
|
||||
CefRefPtr<CefBrowser> browserPtr = CefBrowserCppToC::Get(browser);
|
||||
CefRefPtr<CefFrame> framePtr = browserPtr->GetMainFrame();
|
||||
if(framePtr.get())
|
||||
return CefFrameCppToC::Wrap(framePtr);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct _cef_frame_t* CEF_CALLBACK browser_get_focused_frame(
|
||||
struct _cef_browser_t* browser)
|
||||
{
|
||||
DCHECK(browser);
|
||||
if(!browser)
|
||||
return NULL;
|
||||
return cef_string_alloc(urlStr.c_str());
|
||||
|
||||
CefRefPtr<CefBrowser> browserPtr = CefBrowserCppToC::Get(browser);
|
||||
CefRefPtr<CefFrame> framePtr = browserPtr->GetFocusedFrame();
|
||||
if(framePtr.get())
|
||||
return CefFrameCppToC::Wrap(framePtr);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct _cef_frame_t* CEF_CALLBACK browser_get_frame(
|
||||
struct _cef_browser_t* browser, const wchar_t* name)
|
||||
{
|
||||
DCHECK(browser);
|
||||
if(!browser)
|
||||
return NULL;
|
||||
|
||||
std::wstring nameStr;
|
||||
if(name)
|
||||
nameStr = name;
|
||||
if(nameStr.empty())
|
||||
return NULL;
|
||||
|
||||
CefRefPtr<CefBrowser> browserPtr = CefBrowserCppToC::Get(browser);
|
||||
CefRefPtr<CefFrame> framePtr = browserPtr->GetFrame(nameStr);
|
||||
if(framePtr.get())
|
||||
return CefFrameCppToC::Wrap(framePtr);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
size_t CEF_CALLBACK browser_get_frame_names(struct _cef_browser_t* browser,
|
||||
cef_string_list_t list)
|
||||
{
|
||||
DCHECK(browser);
|
||||
DCHECK(list);
|
||||
if(!browser || !list)
|
||||
return NULL;
|
||||
|
||||
CefRefPtr<CefBrowser> browserPtr = CefBrowserCppToC::Get(browser);
|
||||
std::vector<std::wstring> stringList;
|
||||
browserPtr->GetFrameNames(stringList);
|
||||
size_t size = stringList.size();
|
||||
for(size_t i = 0; i < size; ++i)
|
||||
cef_string_list_append(list, stringList[i].c_str());
|
||||
return size;
|
||||
}
|
||||
|
||||
CefBrowserCppToC::CefBrowserCppToC(CefBrowser* cls)
|
||||
: CefCppToC<CefBrowser, cef_browser_t>(cls)
|
||||
: CefCppToC<CefBrowserCppToC, CefBrowser, cef_browser_t>(cls)
|
||||
{
|
||||
struct_.struct_.can_go_back = browser_can_go_back;
|
||||
struct_.struct_.go_back = browser_go_back;
|
||||
@@ -480,34 +177,16 @@ CefBrowserCppToC::CefBrowserCppToC(CefBrowser* cls)
|
||||
struct_.struct_.go_forward = browser_go_forward;
|
||||
struct_.struct_.reload = browser_reload;
|
||||
struct_.struct_.stop_load = browser_stop_load;
|
||||
struct_.struct_.undo = browser_undo;
|
||||
struct_.struct_.redo = browser_redo;
|
||||
struct_.struct_.cut = browser_cut;
|
||||
struct_.struct_.copy = browser_copy;
|
||||
struct_.struct_.paste = browser_paste;
|
||||
struct_.struct_.del = browser_delete;
|
||||
struct_.struct_.select_all = browser_select_all;
|
||||
struct_.struct_.set_focus = browser_set_focus;
|
||||
struct_.struct_.print = browser_print;
|
||||
struct_.struct_.view_source = browser_view_source;
|
||||
struct_.struct_.get_source = browser_get_source;
|
||||
struct_.struct_.get_text = browser_get_text;
|
||||
struct_.struct_.load_request = browser_load_request;
|
||||
struct_.struct_.load_url = browser_load_url;
|
||||
struct_.struct_.load_string = browser_load_string;
|
||||
struct_.struct_.load_stream = browser_load_stream;
|
||||
struct_.struct_.execute_javascript = browser_execute_javascript;
|
||||
struct_.struct_.add_jshandler = browser_add_jshandler;
|
||||
struct_.struct_.has_jshandler = browser_has_jshandler;
|
||||
struct_.struct_.get_jshandler = browser_get_jshandler;
|
||||
struct_.struct_.remove_jshandler = browser_remove_jshandler;
|
||||
struct_.struct_.remove_all_jshandlers = browser_remove_all_jshandlers;
|
||||
struct_.struct_.get_window_handle = browser_get_window_handle;
|
||||
struct_.struct_.is_popup = browser_is_popup;
|
||||
struct_.struct_.get_handler = browser_get_handler;
|
||||
struct_.struct_.get_url = browser_get_url;
|
||||
struct_.struct_.get_handler = browser_get_handler;
|
||||
struct_.struct_.get_main_frame = browser_get_main_frame;
|
||||
struct_.struct_.get_focused_frame = browser_get_focused_frame;
|
||||
struct_.struct_.get_frame = browser_get_frame;
|
||||
struct_.struct_.get_frame_names = browser_get_frame_names;
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
long CefCppToC<CefBrowser, cef_browser_t>::DebugObjCt = 0;
|
||||
long CefCppToC<CefBrowserCppToC, CefBrowser, cef_browser_t>::DebugObjCt = 0;
|
||||
#endif
|
||||
|
@@ -16,7 +16,8 @@
|
||||
|
||||
// Wrap a C++ browser class with a C browser structure.
|
||||
// This class may be instantiated and accessed DLL-side only.
|
||||
class CefBrowserCppToC : public CefCppToC<CefBrowser, cef_browser_t>
|
||||
class CefBrowserCppToC
|
||||
: public CefCppToC<CefBrowserCppToC, CefBrowser, cef_browser_t>
|
||||
{
|
||||
public:
|
||||
CefBrowserCppToC(CefBrowser* cls);
|
||||
|
@@ -10,19 +10,63 @@
|
||||
#include "../cef_logging.h"
|
||||
|
||||
|
||||
// Wrap a C++ class with a C structure.
|
||||
template <class ClassName, class StructName>
|
||||
// Wrap a C++ class with a C structure. This is used when the class
|
||||
// implementation exists on this side of the DLL boundary but will have methods
|
||||
// called from the other side of the DLL boundary.
|
||||
template <class ClassName, class BaseName, class StructName>
|
||||
class CefCppToC : public CefThreadSafeBase<CefBase>
|
||||
{
|
||||
public:
|
||||
// Use this method to retrieve the underlying class instance from our
|
||||
// own structure when the structure is passed as the required first
|
||||
// parameter of a C API function call. No explicit reference counting
|
||||
// is done in this case.
|
||||
static CefRefPtr<BaseName> Get(StructName* s)
|
||||
{
|
||||
// Cast our structure to the wrapper structure type.
|
||||
ClassName::Struct* wrapperStruct =
|
||||
reinterpret_cast<ClassName::Struct*>(s);
|
||||
// Return the underlying object instance.
|
||||
return wrapperStruct->class_->GetClass();
|
||||
}
|
||||
|
||||
// Use this method to create a wrapper structure for passing our class
|
||||
// instance to the other side.
|
||||
static StructName* Wrap(CefRefPtr<BaseName> c)
|
||||
{
|
||||
// Wrap our object with the CefCppToC class.
|
||||
ClassName* wrapper = new ClassName(c);
|
||||
// Add a reference to our wrapper object that will be released once our
|
||||
// structure arrives on the other side.
|
||||
wrapper->AddRef();
|
||||
// Return the structure pointer that can now be passed to the other side.
|
||||
return wrapper->GetStruct();
|
||||
}
|
||||
|
||||
// Use this method to retrieve the underlying class instance when receiving
|
||||
// our wrapper structure back from the other side.
|
||||
static CefRefPtr<BaseName> Unwrap(StructName* s)
|
||||
{
|
||||
// Cast our structure to the wrapper structure type.
|
||||
ClassName::Struct* wrapperStruct =
|
||||
reinterpret_cast<ClassName::Struct*>(s);
|
||||
// Add the underlying object instance to a smart pointer.
|
||||
CefRefPtr<BaseName> objectPtr(wrapperStruct->class_->GetClass());
|
||||
// Release the reference to our wrapper object that was added before the
|
||||
// structure was passed back to us.
|
||||
wrapperStruct->class_->Release();
|
||||
// Return the underlying object instance.
|
||||
return objectPtr;
|
||||
}
|
||||
|
||||
// Structure representation with pointer to the C++ class.
|
||||
struct Struct
|
||||
{
|
||||
StructName struct_;
|
||||
CefCppToC<ClassName, StructName>* class_;
|
||||
CefCppToC<ClassName,BaseName,StructName>* class_;
|
||||
};
|
||||
|
||||
CefCppToC(ClassName* cls)
|
||||
CefCppToC(BaseName* cls)
|
||||
: class_(cls)
|
||||
{
|
||||
DCHECK(cls);
|
||||
@@ -47,7 +91,7 @@ public:
|
||||
#endif
|
||||
}
|
||||
|
||||
ClassName* GetClass() { return class_; }
|
||||
BaseName* GetClass() { return class_; }
|
||||
|
||||
// If returning the structure across the DLL boundary you should call
|
||||
// AddRef() on this CefCppToC object. On the other side of the DLL boundary,
|
||||
@@ -110,7 +154,137 @@ private:
|
||||
|
||||
protected:
|
||||
Struct struct_;
|
||||
ClassName* class_;
|
||||
BaseName* class_;
|
||||
};
|
||||
|
||||
// CefCppToC implementation for CefBase.
|
||||
class CefBaseCppToC : public CefThreadSafeBase<CefBase>
|
||||
{
|
||||
public:
|
||||
// Use this method to retrieve the underlying class instance from our
|
||||
// own structure when the structure is passed as the required first
|
||||
// parameter of a C API function call. No explicit reference counting
|
||||
// is done in this case.
|
||||
static CefRefPtr<CefBase> Get(cef_base_t* s)
|
||||
{
|
||||
// Cast our structure to the wrapper structure type.
|
||||
CefBaseCppToC::Struct* wrapperStruct =
|
||||
reinterpret_cast<CefBaseCppToC::Struct*>(s);
|
||||
// Return the underlying object instance.
|
||||
return wrapperStruct->class_->GetClass();
|
||||
}
|
||||
|
||||
// Use this method to create a wrapper structure for passing our class
|
||||
// instance to the other side.
|
||||
static cef_base_t* Wrap(CefRefPtr<CefBase> c)
|
||||
{
|
||||
// Wrap our object with the CefCppToC class.
|
||||
CefBaseCppToC* wrapper = new CefBaseCppToC(c);
|
||||
// Add a reference to our wrapper object that will be released once our
|
||||
// structure arrives on the other side.
|
||||
wrapper->AddRef();
|
||||
// Return the structure pointer that can now be passed to the other side.
|
||||
return wrapper->GetStruct();
|
||||
}
|
||||
|
||||
// Use this method to retrieve the underlying class instance when receiving
|
||||
// our wrapper structure back from the other side.
|
||||
static CefRefPtr<CefBase> Unwrap(cef_base_t* s)
|
||||
{
|
||||
// Cast our structure to the wrapper structure type.
|
||||
CefBaseCppToC::Struct* wrapperStruct =
|
||||
reinterpret_cast<CefBaseCppToC::Struct*>(s);
|
||||
// Add the underlying object instance to a smart pointer.
|
||||
CefRefPtr<CefBase> objectPtr(wrapperStruct->class_->GetClass());
|
||||
// Release the reference to our wrapper object that was added before the
|
||||
// structure was passed back to us.
|
||||
wrapperStruct->class_->Release();
|
||||
// Return the underlying object instance.
|
||||
return objectPtr;
|
||||
}
|
||||
|
||||
// Structure representation with pointer to the C++ class.
|
||||
struct Struct
|
||||
{
|
||||
cef_base_t struct_;
|
||||
CefBaseCppToC* class_;
|
||||
};
|
||||
|
||||
CefBaseCppToC(CefBase* cls)
|
||||
: class_(cls)
|
||||
{
|
||||
DCHECK(cls);
|
||||
|
||||
struct_.class_ = this;
|
||||
|
||||
// zero the underlying structure and set base members
|
||||
memset(&struct_.struct_, 0, sizeof(cef_base_t));
|
||||
struct_.struct_.size = sizeof(cef_base_t);
|
||||
struct_.struct_.add_ref = struct_add_ref;
|
||||
struct_.struct_.release = struct_release;
|
||||
struct_.struct_.get_refct = struct_get_refct;
|
||||
}
|
||||
virtual ~CefBaseCppToC() {}
|
||||
|
||||
CefBase* GetClass() { return class_; }
|
||||
|
||||
// If returning the structure across the DLL boundary you should call
|
||||
// AddRef() on this CefCppToC object. On the other side of the DLL boundary,
|
||||
// call UnderlyingRelease() on the wrapping CefCToCpp object.
|
||||
cef_base_t* GetStruct() { return &struct_.struct_; }
|
||||
|
||||
// CefBase methods increment/decrement reference counts on both this object
|
||||
// and the underlying wrapper class.
|
||||
virtual int AddRef()
|
||||
{
|
||||
UnderlyingAddRef();
|
||||
return CefThreadSafeBase<CefBase>::AddRef();
|
||||
}
|
||||
virtual int Release()
|
||||
{
|
||||
UnderlyingRelease();
|
||||
return CefThreadSafeBase<CefBase>::Release();
|
||||
}
|
||||
|
||||
// Increment/decrement reference counts on only the underlying class.
|
||||
int UnderlyingAddRef() { return class_->AddRef(); }
|
||||
int UnderlyingRelease() { return class_->Release(); }
|
||||
int UnderlyingGetRefCt() { return class_->GetRefCt(); }
|
||||
|
||||
private:
|
||||
static int CEF_CALLBACK struct_add_ref(struct _cef_base_t* base)
|
||||
{
|
||||
DCHECK(base);
|
||||
if(!base)
|
||||
return 0;
|
||||
|
||||
Struct* impl = reinterpret_cast<Struct*>(base);
|
||||
return impl->class_->AddRef();
|
||||
}
|
||||
|
||||
static int CEF_CALLBACK struct_release(struct _cef_base_t* base)
|
||||
{
|
||||
DCHECK(base);
|
||||
if(!base)
|
||||
return 0;
|
||||
|
||||
Struct* impl = reinterpret_cast<Struct*>(base);
|
||||
return impl->class_->Release();
|
||||
}
|
||||
|
||||
static int CEF_CALLBACK struct_get_refct(struct _cef_base_t* base)
|
||||
{
|
||||
DCHECK(base);
|
||||
if(!base)
|
||||
return 0;
|
||||
|
||||
Struct* impl = reinterpret_cast<Struct*>(base);
|
||||
return impl->class_->GetRefCt();
|
||||
}
|
||||
|
||||
protected:
|
||||
Struct struct_;
|
||||
CefBase* class_;
|
||||
};
|
||||
|
||||
#endif // _CPPTOC_H
|
||||
|
262
libcef_dll/cpptoc/frame_cpptoc.cc
Normal file
262
libcef_dll/cpptoc/frame_cpptoc.cc
Normal file
@@ -0,0 +1,262 @@
|
||||
// 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/frame_cpptoc.h"
|
||||
#include "cpptoc/request_cpptoc.h"
|
||||
#include "cpptoc/stream_cpptoc.h"
|
||||
|
||||
|
||||
void CEF_CALLBACK frame_undo(cef_frame_t* frame)
|
||||
{
|
||||
DCHECK(frame);
|
||||
if(!frame)
|
||||
return;
|
||||
|
||||
CefFrameCppToC::Get(frame)->Undo();
|
||||
}
|
||||
|
||||
void CEF_CALLBACK frame_redo(cef_frame_t* frame)
|
||||
{
|
||||
DCHECK(frame);
|
||||
if(!frame)
|
||||
return;
|
||||
|
||||
CefFrameCppToC::Get(frame)->Redo();
|
||||
}
|
||||
|
||||
void CEF_CALLBACK frame_cut(cef_frame_t* frame)
|
||||
{
|
||||
DCHECK(frame);
|
||||
if(!frame)
|
||||
return;
|
||||
|
||||
CefFrameCppToC::Get(frame)->Cut();
|
||||
}
|
||||
|
||||
void CEF_CALLBACK frame_copy(cef_frame_t* frame)
|
||||
{
|
||||
DCHECK(frame);
|
||||
if(!frame)
|
||||
return;
|
||||
|
||||
CefFrameCppToC::Get(frame)->Copy();
|
||||
}
|
||||
|
||||
void CEF_CALLBACK frame_paste(cef_frame_t* frame)
|
||||
{
|
||||
DCHECK(frame);
|
||||
if(!frame)
|
||||
return;
|
||||
|
||||
CefFrameCppToC::Get(frame)->Paste();
|
||||
}
|
||||
|
||||
void CEF_CALLBACK frame_delete(cef_frame_t* frame)
|
||||
{
|
||||
DCHECK(frame);
|
||||
if(!frame)
|
||||
return;
|
||||
|
||||
CefFrameCppToC::Get(frame)->Delete();
|
||||
}
|
||||
|
||||
void CEF_CALLBACK frame_select_all(cef_frame_t* frame)
|
||||
{
|
||||
DCHECK(frame);
|
||||
if(!frame)
|
||||
return;
|
||||
|
||||
CefFrameCppToC::Get(frame)->SelectAll();
|
||||
}
|
||||
|
||||
void CEF_CALLBACK frame_print(cef_frame_t* frame)
|
||||
{
|
||||
DCHECK(frame);
|
||||
if(!frame)
|
||||
return;
|
||||
|
||||
CefFrameCppToC::Get(frame)->Print();
|
||||
}
|
||||
|
||||
void CEF_CALLBACK frame_view_source(cef_frame_t* frame)
|
||||
{
|
||||
DCHECK(frame);
|
||||
if(!frame)
|
||||
return;
|
||||
|
||||
CefFrameCppToC::Get(frame)->ViewSource();
|
||||
}
|
||||
|
||||
cef_string_t CEF_CALLBACK frame_get_source(cef_frame_t* frame)
|
||||
{
|
||||
DCHECK(frame);
|
||||
if(!frame)
|
||||
return NULL;
|
||||
|
||||
std::wstring sourceStr = CefFrameCppToC::Get(frame)->GetSource();
|
||||
if(!sourceStr.empty())
|
||||
return cef_string_alloc(sourceStr.c_str());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cef_string_t CEF_CALLBACK frame_get_text(cef_frame_t* frame)
|
||||
{
|
||||
DCHECK(frame);
|
||||
if(!frame)
|
||||
return NULL;
|
||||
|
||||
std::wstring textStr = CefFrameCppToC::Get(frame)->GetText();
|
||||
if(!textStr.empty())
|
||||
return cef_string_alloc(textStr.c_str());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void CEF_CALLBACK frame_load_request(cef_frame_t* frame,
|
||||
cef_request_t* request)
|
||||
{
|
||||
DCHECK(frame);
|
||||
DCHECK(request);
|
||||
if(!frame || !request)
|
||||
return;
|
||||
|
||||
CefRefPtr<CefRequest> requestPtr = CefRequestCppToC::Unwrap(request);
|
||||
CefFrameCppToC::Get(frame)->LoadRequest(requestPtr);
|
||||
}
|
||||
|
||||
void CEF_CALLBACK frame_load_url(cef_frame_t* frame, const wchar_t* url)
|
||||
{
|
||||
DCHECK(frame);
|
||||
if(!frame)
|
||||
return;
|
||||
|
||||
std::wstring urlStr;
|
||||
if(url)
|
||||
urlStr = url;
|
||||
CefFrameCppToC::Get(frame)->LoadURL(urlStr);
|
||||
}
|
||||
|
||||
void CEF_CALLBACK frame_load_string(cef_frame_t* frame,
|
||||
const wchar_t* string,
|
||||
const wchar_t* url)
|
||||
{
|
||||
DCHECK(frame);
|
||||
if(!frame)
|
||||
return;
|
||||
|
||||
std::wstring stringStr, urlStr;
|
||||
if(string)
|
||||
stringStr = string;
|
||||
if(url)
|
||||
urlStr = url;
|
||||
CefFrameCppToC::Get(frame)->LoadString(stringStr, urlStr);
|
||||
}
|
||||
|
||||
void CEF_CALLBACK frame_load_stream(cef_frame_t* frame,
|
||||
cef_stream_reader_t* stream,
|
||||
const wchar_t* url)
|
||||
{
|
||||
DCHECK(frame);
|
||||
DCHECK(stream);
|
||||
if(!frame || !stream)
|
||||
return;
|
||||
|
||||
CefRefPtr<CefStreamReader> streamPtr = CefStreamReaderCppToC::Unwrap(stream);
|
||||
std::wstring urlStr;
|
||||
if(url)
|
||||
urlStr = url;
|
||||
|
||||
CefFrameCppToC::Get(frame)->LoadStream(streamPtr, urlStr);
|
||||
}
|
||||
|
||||
void CEF_CALLBACK frame_execute_javascript(cef_frame_t* frame,
|
||||
const wchar_t* jsCode,
|
||||
const wchar_t* scriptUrl,
|
||||
int startLine)
|
||||
{
|
||||
DCHECK(frame);
|
||||
if(!frame)
|
||||
return;
|
||||
|
||||
std::wstring jsCodeStr, scriptUrlStr;
|
||||
if(jsCode)
|
||||
jsCodeStr = jsCode;
|
||||
if(scriptUrl)
|
||||
scriptUrlStr = scriptUrl;
|
||||
|
||||
CefFrameCppToC::Get(frame)->ExecuteJavaScript(jsCodeStr, scriptUrlStr,
|
||||
startLine);
|
||||
}
|
||||
|
||||
int CEF_CALLBACK frame_is_main(struct _cef_frame_t* frame)
|
||||
{
|
||||
DCHECK(frame);
|
||||
if(!frame)
|
||||
return 0;
|
||||
|
||||
return CefFrameCppToC::Get(frame)->IsMain();
|
||||
}
|
||||
|
||||
int CEF_CALLBACK frame_is_focused(struct _cef_frame_t* frame)
|
||||
{
|
||||
DCHECK(frame);
|
||||
if(!frame)
|
||||
return 0;
|
||||
|
||||
return CefFrameCppToC::Get(frame)->IsFocused();
|
||||
}
|
||||
|
||||
|
||||
cef_string_t CEF_CALLBACK frame_get_name(struct _cef_frame_t* frame)
|
||||
{
|
||||
DCHECK(frame);
|
||||
if(!frame)
|
||||
return 0;
|
||||
|
||||
std::wstring nameStr = CefFrameCppToC::Get(frame)->GetName();
|
||||
if(!nameStr.empty())
|
||||
return cef_string_alloc(nameStr.c_str());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cef_string_t CEF_CALLBACK frame_get_url(cef_frame_t* frame)
|
||||
{
|
||||
DCHECK(frame);
|
||||
if(!frame)
|
||||
return NULL;
|
||||
|
||||
std::wstring urlStr = CefFrameCppToC::Get(frame)->GetURL();
|
||||
if(!urlStr.empty())
|
||||
return cef_string_alloc(urlStr.c_str());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CefFrameCppToC::CefFrameCppToC(CefFrame* cls)
|
||||
: CefCppToC<CefFrameCppToC, CefFrame, cef_frame_t>(cls)
|
||||
{
|
||||
struct_.struct_.undo = frame_undo;
|
||||
struct_.struct_.redo = frame_redo;
|
||||
struct_.struct_.cut = frame_cut;
|
||||
struct_.struct_.copy = frame_copy;
|
||||
struct_.struct_.paste = frame_paste;
|
||||
struct_.struct_.del = frame_delete;
|
||||
struct_.struct_.select_all = frame_select_all;
|
||||
struct_.struct_.print = frame_print;
|
||||
struct_.struct_.view_source = frame_view_source;
|
||||
struct_.struct_.get_source = frame_get_source;
|
||||
struct_.struct_.get_text = frame_get_text;
|
||||
struct_.struct_.load_request = frame_load_request;
|
||||
struct_.struct_.load_url = frame_load_url;
|
||||
struct_.struct_.load_string = frame_load_string;
|
||||
struct_.struct_.load_stream = frame_load_stream;
|
||||
struct_.struct_.execute_javascript = frame_execute_javascript;
|
||||
struct_.struct_.is_main = frame_is_main;
|
||||
struct_.struct_.is_focused = frame_is_focused;
|
||||
struct_.struct_.get_name = frame_get_name;
|
||||
struct_.struct_.get_url = frame_get_url;
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
long CefCppToC<CefFrameCppToC, CefFrame, cef_frame_t>::DebugObjCt = 0;
|
||||
#endif
|
@@ -2,8 +2,8 @@
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
|
||||
#ifndef _VARIANT_CPPTOC_H
|
||||
#define _VARIANT_CPPTOC_H
|
||||
#ifndef _FRAME_CPPTOC_H
|
||||
#define _FRAME_CPPTOC_H
|
||||
|
||||
#ifndef BUILDING_CEF_SHARED
|
||||
#pragma message("Warning: "__FILE__" may be accessed DLL-side only")
|
||||
@@ -14,15 +14,16 @@
|
||||
#include "cpptoc.h"
|
||||
|
||||
|
||||
// Wrap a C++ browser class with a C browser structure.
|
||||
// Wrap a C++ frame class with a C frame structure.
|
||||
// This class may be instantiated and accessed DLL-side only.
|
||||
class CefVariantCppToC : public CefCppToC<CefVariant, cef_variant_t>
|
||||
class CefFrameCppToC
|
||||
: public CefCppToC<CefFrameCppToC, CefFrame, cef_frame_t>
|
||||
{
|
||||
public:
|
||||
CefVariantCppToC(CefVariant* cls);
|
||||
virtual ~CefVariantCppToC() {}
|
||||
CefFrameCppToC(CefFrame* cls);
|
||||
virtual ~CefFrameCppToC() {}
|
||||
};
|
||||
|
||||
|
||||
#endif // BUILDING_CEF_SHARED
|
||||
#endif // _VARIANT_CPPTOC_H
|
||||
#endif // _FRAME_CPPTOC_H
|
@@ -5,8 +5,10 @@
|
||||
#include "../precompiled_libcef.h"
|
||||
#include "cpptoc/handler_cpptoc.h"
|
||||
#include "ctocpp/browser_ctocpp.h"
|
||||
#include "ctocpp/frame_ctocpp.h"
|
||||
#include "ctocpp/request_ctocpp.h"
|
||||
#include "ctocpp/stream_ctocpp.h"
|
||||
#include "ctocpp/v8value_ctocpp.h"
|
||||
#include "transfer_util.h"
|
||||
|
||||
|
||||
@@ -22,42 +24,29 @@ enum cef_retval_t CEF_CALLBACK handler_handle_before_created(
|
||||
if(!handler || !windowInfo || !newHandler || !*newHandler || !url)
|
||||
return RV_CONTINUE;
|
||||
|
||||
CefHandlerCppToC::Struct* impl =
|
||||
reinterpret_cast<CefHandlerCppToC::Struct*>(handler);
|
||||
CefWindowInfo wndInfo(*windowInfo);
|
||||
|
||||
// |newHandler| will start off pointing to the current handler.
|
||||
CefHandlerCppToC::Struct* structPtr
|
||||
= reinterpret_cast<CefHandlerCppToC::Struct*>(*newHandler);
|
||||
|
||||
CefWindowInfo wndInfo(*windowInfo);
|
||||
CefRefPtr<CefBrowser> browserPtr;
|
||||
CefRefPtr<CefHandler> handlerPtr(structPtr->class_->GetClass());
|
||||
structPtr->class_->Release();
|
||||
|
||||
std::wstring urlStr;
|
||||
CefRefPtr<CefHandler> handlerPtr = CefHandlerCppToC::Unwrap(*newHandler);
|
||||
CefHandler* origHandler = handlerPtr.get();
|
||||
|
||||
// |parentBrowser| will be NULL if this is a top-level browser window.
|
||||
CefRefPtr<CefBrowser> browserPtr;
|
||||
if(parentBrowser)
|
||||
{
|
||||
CefBrowserCToCpp* bp = new CefBrowserCToCpp(parentBrowser);
|
||||
browserPtr = bp;
|
||||
bp->UnderlyingRelease();
|
||||
}
|
||||
browserPtr = CefBrowserCToCpp::Wrap(parentBrowser);
|
||||
|
||||
std::wstring urlStr;
|
||||
if(*url)
|
||||
urlStr = *url;
|
||||
|
||||
enum cef_retval_t rv = impl->class_->GetClass()->HandleBeforeCreated(
|
||||
enum cef_retval_t rv = CefHandlerCppToC::Get(handler)->HandleBeforeCreated(
|
||||
browserPtr, wndInfo, popup, handlerPtr, urlStr);
|
||||
|
||||
transfer_string_contents(urlStr, url);
|
||||
|
||||
if(handlerPtr.get() != structPtr->class_->GetClass())
|
||||
{
|
||||
if(handlerPtr.get() != origHandler) {
|
||||
// The handler has been changed.
|
||||
CefHandlerCppToC* hobj = new CefHandlerCppToC(handlerPtr);
|
||||
hobj->AddRef();
|
||||
*newHandler = hobj->GetStruct();
|
||||
*newHandler = CefHandlerCppToC::Wrap(handlerPtr);
|
||||
}
|
||||
|
||||
// WindowInfo may or may not have changed.
|
||||
@@ -79,37 +68,26 @@ enum cef_retval_t CEF_CALLBACK handler_handle_after_created(
|
||||
if(!handler || !browser)
|
||||
return RV_CONTINUE;
|
||||
|
||||
CefHandlerCppToC::Struct* impl =
|
||||
reinterpret_cast<CefHandlerCppToC::Struct*>(handler);
|
||||
|
||||
CefBrowserCToCpp* bp = new CefBrowserCToCpp(browser);
|
||||
CefRefPtr<CefBrowser> browserPtr(bp);
|
||||
bp->UnderlyingRelease();
|
||||
|
||||
return impl->class_->GetClass()->HandleAfterCreated(browserPtr);
|
||||
return CefHandlerCppToC::Get(handler)->HandleAfterCreated(
|
||||
CefBrowserCToCpp::Wrap(browser));
|
||||
}
|
||||
|
||||
enum cef_retval_t CEF_CALLBACK handler_handle_address_change(
|
||||
struct _cef_handler_t* handler, cef_browser_t* browser,
|
||||
struct _cef_handler_t* handler, cef_browser_t* browser, cef_frame_t* frame,
|
||||
const wchar_t* url)
|
||||
{
|
||||
DCHECK(handler);
|
||||
DCHECK(browser);
|
||||
if(!handler || !browser)
|
||||
DCHECK(frame);
|
||||
if(!handler || !browser || !frame)
|
||||
return RV_CONTINUE;
|
||||
|
||||
CefHandlerCppToC::Struct* impl =
|
||||
reinterpret_cast<CefHandlerCppToC::Struct*>(handler);
|
||||
|
||||
CefBrowserCToCpp* bp = new CefBrowserCToCpp(browser);
|
||||
CefRefPtr<CefBrowser> browserPtr(bp);
|
||||
bp->UnderlyingRelease();
|
||||
|
||||
std::wstring urlStr;
|
||||
if(url)
|
||||
urlStr = url;
|
||||
|
||||
return impl->class_->GetClass()->HandleAddressChange(browserPtr, urlStr);
|
||||
return CefHandlerCppToC::Get(handler)->HandleAddressChange(
|
||||
CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame), urlStr);
|
||||
}
|
||||
|
||||
enum cef_retval_t CEF_CALLBACK handler_handle_title_change(
|
||||
@@ -121,100 +99,75 @@ enum cef_retval_t CEF_CALLBACK handler_handle_title_change(
|
||||
if(!handler || !browser)
|
||||
return RV_CONTINUE;
|
||||
|
||||
CefHandlerCppToC::Struct* impl =
|
||||
reinterpret_cast<CefHandlerCppToC::Struct*>(handler);
|
||||
|
||||
CefBrowserCToCpp* bp = new CefBrowserCToCpp(browser);
|
||||
CefRefPtr<CefBrowser> browserPtr(bp);
|
||||
bp->UnderlyingRelease();
|
||||
|
||||
std::wstring titleStr;
|
||||
if(title)
|
||||
titleStr = title;
|
||||
|
||||
return impl->class_->GetClass()->HandleTitleChange(browserPtr, titleStr);
|
||||
return CefHandlerCppToC::Get(handler)->HandleTitleChange(
|
||||
CefBrowserCToCpp::Wrap(browser), titleStr);
|
||||
}
|
||||
|
||||
enum cef_retval_t CEF_CALLBACK handler_handle_before_browse(
|
||||
struct _cef_handler_t* handler, cef_browser_t* browser,
|
||||
struct _cef_handler_t* handler, cef_browser_t* browser, cef_frame_t* frame,
|
||||
struct _cef_request_t* request, cef_handler_navtype_t navType,
|
||||
int isRedirect)
|
||||
{
|
||||
DCHECK(handler);
|
||||
DCHECK(browser);
|
||||
DCHECK(frame);
|
||||
DCHECK(request);
|
||||
if(!handler || !browser || !request)
|
||||
if(!handler || !browser || !request || !frame)
|
||||
return RV_CONTINUE;
|
||||
|
||||
CefHandlerCppToC::Struct* impl =
|
||||
reinterpret_cast<CefHandlerCppToC::Struct*>(handler);
|
||||
|
||||
CefBrowserCToCpp* bp = new CefBrowserCToCpp(browser);
|
||||
CefRefPtr<CefBrowser> browserPtr(bp);
|
||||
bp->UnderlyingRelease();
|
||||
|
||||
CefRequestCToCpp* rp = new CefRequestCToCpp(request);
|
||||
CefRefPtr<CefRequest> requestPtr(rp);
|
||||
rp->UnderlyingRelease();
|
||||
|
||||
return impl->class_->GetClass()->HandleBeforeBrowse(browserPtr, requestPtr,
|
||||
navType, (isRedirect ? true : false));
|
||||
return CefHandlerCppToC::Get(handler)->HandleBeforeBrowse(
|
||||
CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame),
|
||||
CefRequestCToCpp::Wrap(request), navType, (isRedirect ? true : false));
|
||||
}
|
||||
|
||||
enum cef_retval_t CEF_CALLBACK handler_handle_load_start(
|
||||
struct _cef_handler_t* handler, cef_browser_t* browser)
|
||||
struct _cef_handler_t* handler, cef_browser_t* browser, cef_frame_t* frame)
|
||||
{
|
||||
DCHECK(handler);
|
||||
DCHECK(browser);
|
||||
if(!handler || !browser)
|
||||
return RV_CONTINUE;
|
||||
|
||||
CefHandlerCppToC::Struct* impl =
|
||||
reinterpret_cast<CefHandlerCppToC::Struct*>(handler);
|
||||
|
||||
CefBrowserCToCpp* bp = new CefBrowserCToCpp(browser);
|
||||
CefRefPtr<CefBrowser> browserPtr(bp);
|
||||
bp->UnderlyingRelease();
|
||||
CefRefPtr<CefFrame> framePtr;
|
||||
if(frame)
|
||||
framePtr = CefFrameCToCpp::Wrap(frame);
|
||||
|
||||
return impl->class_->GetClass()->HandleLoadStart(browserPtr);
|
||||
return CefHandlerCppToC::Get(handler)->HandleLoadStart(
|
||||
CefBrowserCToCpp::Wrap(browser), framePtr);
|
||||
}
|
||||
|
||||
enum cef_retval_t CEF_CALLBACK handler_handle_load_end(
|
||||
struct _cef_handler_t* handler, cef_browser_t* browser)
|
||||
struct _cef_handler_t* handler, cef_browser_t* browser, cef_frame_t* frame)
|
||||
{
|
||||
DCHECK(handler);
|
||||
DCHECK(browser);
|
||||
if(!handler || !browser)
|
||||
return RV_CONTINUE;
|
||||
|
||||
CefHandlerCppToC::Struct* impl =
|
||||
reinterpret_cast<CefHandlerCppToC::Struct*>(handler);
|
||||
|
||||
CefBrowserCToCpp* bp = new CefBrowserCToCpp(browser);
|
||||
CefRefPtr<CefBrowser> browserPtr(bp);
|
||||
bp->UnderlyingRelease();
|
||||
CefRefPtr<CefFrame> framePtr;
|
||||
if(frame)
|
||||
framePtr = CefFrameCToCpp::Wrap(frame);
|
||||
|
||||
return impl->class_->GetClass()->HandleLoadEnd(browserPtr);
|
||||
return CefHandlerCppToC::Get(handler)->HandleLoadEnd(
|
||||
CefBrowserCToCpp::Wrap(browser), framePtr);
|
||||
}
|
||||
|
||||
enum cef_retval_t CEF_CALLBACK handler_handle_load_error(
|
||||
struct _cef_handler_t* handler, cef_browser_t* browser,
|
||||
struct _cef_handler_t* handler, cef_browser_t* browser, cef_frame_t* frame,
|
||||
cef_handler_errorcode_t errorCode, const wchar_t* failedUrl,
|
||||
cef_string_t* errorText)
|
||||
{
|
||||
DCHECK(handler);
|
||||
DCHECK(browser);
|
||||
DCHECK(frame);
|
||||
DCHECK(errorText);
|
||||
if(!handler || !browser || !errorText)
|
||||
if(!handler || !browser || !errorText || !frame)
|
||||
return RV_CONTINUE;
|
||||
|
||||
CefHandlerCppToC::Struct* impl =
|
||||
reinterpret_cast<CefHandlerCppToC::Struct*>(handler);
|
||||
|
||||
CefBrowserCToCpp* bp = new CefBrowserCToCpp(browser);
|
||||
CefRefPtr<CefBrowser> browserPtr(bp);
|
||||
bp->UnderlyingRelease();
|
||||
|
||||
std::wstring failedUrlStr, errorTextStr;
|
||||
|
||||
if(failedUrl)
|
||||
@@ -222,8 +175,9 @@ enum cef_retval_t CEF_CALLBACK handler_handle_load_error(
|
||||
if(*errorText)
|
||||
errorTextStr = *errorText;
|
||||
|
||||
enum cef_retval_t rv = impl->class_->GetClass()->HandleLoadError(browserPtr,
|
||||
errorCode, failedUrlStr, errorTextStr);
|
||||
enum cef_retval_t rv = CefHandlerCppToC::Get(handler)->HandleLoadError(
|
||||
CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame), errorCode,
|
||||
failedUrlStr, errorTextStr);
|
||||
|
||||
transfer_string_contents(errorTextStr, errorText);
|
||||
|
||||
@@ -244,17 +198,6 @@ enum cef_retval_t CEF_CALLBACK handler_handle_before_resource_load(
|
||||
if(!handler || !browser || !redirectUrl || !resourceStream || !mimeType)
|
||||
return RV_CONTINUE;
|
||||
|
||||
CefHandlerCppToC::Struct* impl =
|
||||
reinterpret_cast<CefHandlerCppToC::Struct*>(handler);
|
||||
|
||||
CefBrowserCToCpp* bp = new CefBrowserCToCpp(browser);
|
||||
CefRefPtr<CefBrowser> browserPtr(bp);
|
||||
bp->UnderlyingRelease();
|
||||
|
||||
CefRequestCToCpp* rp = new CefRequestCToCpp(request);
|
||||
CefRefPtr<CefRequest> requestPtr(rp);
|
||||
rp->UnderlyingRelease();
|
||||
|
||||
std::wstring redirectUrlStr, mimeTypeStr;
|
||||
CefRefPtr<CefStreamReader> streamPtr;
|
||||
|
||||
@@ -263,20 +206,16 @@ enum cef_retval_t CEF_CALLBACK handler_handle_before_resource_load(
|
||||
if(*mimeType)
|
||||
mimeTypeStr = *mimeType;
|
||||
|
||||
enum cef_retval_t rv = impl->class_->GetClass()->HandleBeforeResourceLoad(
|
||||
browserPtr, requestPtr, redirectUrlStr, streamPtr, mimeTypeStr,
|
||||
enum cef_retval_t rv = CefHandlerCppToC::Get(handler)->
|
||||
HandleBeforeResourceLoad(CefBrowserCToCpp::Wrap(browser),
|
||||
CefRequestCToCpp::Wrap(request), redirectUrlStr, streamPtr, mimeTypeStr,
|
||||
loadFlags);
|
||||
|
||||
transfer_string_contents(redirectUrlStr, redirectUrl);
|
||||
transfer_string_contents(mimeTypeStr, mimeType);
|
||||
|
||||
if(streamPtr.get())
|
||||
{
|
||||
CefStreamReaderCToCpp* sp =
|
||||
static_cast<CefStreamReaderCToCpp*>(streamPtr.get());
|
||||
sp->UnderlyingAddRef();
|
||||
*resourceStream = sp->GetStruct();
|
||||
}
|
||||
*resourceStream = CefStreamReaderCToCpp::Unwrap(streamPtr);
|
||||
|
||||
return rv;
|
||||
}
|
||||
@@ -291,14 +230,8 @@ enum cef_retval_t CEF_CALLBACK handler_handle_before_menu(
|
||||
if(!handler || !browser || !menuInfo)
|
||||
return RV_CONTINUE;
|
||||
|
||||
CefHandlerCppToC::Struct* impl =
|
||||
reinterpret_cast<CefHandlerCppToC::Struct*>(handler);
|
||||
|
||||
CefBrowserCToCpp* bp = new CefBrowserCToCpp(browser);
|
||||
CefRefPtr<CefBrowser> browserPtr(bp);
|
||||
bp->UnderlyingRelease();
|
||||
|
||||
return impl->class_->GetClass()->HandleBeforeMenu(browserPtr, *menuInfo);
|
||||
return CefHandlerCppToC::Get(handler)->HandleBeforeMenu(
|
||||
CefBrowserCToCpp::Wrap(browser), *menuInfo);
|
||||
}
|
||||
|
||||
enum cef_retval_t CEF_CALLBACK handler_handle_get_menu_label(
|
||||
@@ -311,19 +244,12 @@ enum cef_retval_t CEF_CALLBACK handler_handle_get_menu_label(
|
||||
if(!handler || !browser || !label)
|
||||
return RV_CONTINUE;
|
||||
|
||||
CefHandlerCppToC::Struct* impl =
|
||||
reinterpret_cast<CefHandlerCppToC::Struct*>(handler);
|
||||
|
||||
CefBrowserCToCpp* bp = new CefBrowserCToCpp(browser);
|
||||
CefRefPtr<CefBrowser> browserPtr(bp);
|
||||
bp->UnderlyingRelease();
|
||||
|
||||
std::wstring labelStr;
|
||||
if(*label)
|
||||
labelStr = *label;
|
||||
|
||||
enum cef_retval_t rv = impl->class_->GetClass()->HandleGetMenuLabel(
|
||||
browserPtr, menuId, labelStr);
|
||||
enum cef_retval_t rv = CefHandlerCppToC::Get(handler)->HandleGetMenuLabel(
|
||||
CefBrowserCToCpp::Wrap(browser), menuId, labelStr);
|
||||
|
||||
transfer_string_contents(labelStr, label);
|
||||
|
||||
@@ -339,18 +265,12 @@ enum cef_retval_t CEF_CALLBACK handler_handle_menu_action(
|
||||
if(!handler || !browser)
|
||||
return RV_CONTINUE;
|
||||
|
||||
CefHandlerCppToC::Struct* impl =
|
||||
reinterpret_cast<CefHandlerCppToC::Struct*>(handler);
|
||||
|
||||
CefBrowserCToCpp* bp = new CefBrowserCToCpp(browser);
|
||||
CefRefPtr<CefBrowser> browserPtr(bp);
|
||||
bp->UnderlyingRelease();
|
||||
|
||||
return impl->class_->GetClass()->HandleMenuAction(browserPtr, menuId);
|
||||
return CefHandlerCppToC::Get(handler)->HandleMenuAction(
|
||||
CefBrowserCToCpp::Wrap(browser), menuId);
|
||||
}
|
||||
|
||||
enum cef_retval_t CEF_CALLBACK handler_handle_print_header_footer(
|
||||
struct _cef_handler_t* handler, cef_browser_t* browser,
|
||||
struct _cef_handler_t* handler, cef_browser_t* browser, cef_frame_t* frame,
|
||||
cef_print_info_t* printInfo, const wchar_t* url, const wchar_t* title,
|
||||
int currentPage, int maxPages, cef_string_t* topLeft,
|
||||
cef_string_t* topCenter, cef_string_t* topRight,
|
||||
@@ -359,20 +279,14 @@ enum cef_retval_t CEF_CALLBACK handler_handle_print_header_footer(
|
||||
{
|
||||
DCHECK(handler);
|
||||
DCHECK(browser);
|
||||
DCHECK(frame);
|
||||
DCHECK(printInfo);
|
||||
DCHECK(topLeft && topCenter && topRight);
|
||||
DCHECK(bottomLeft && bottomCenter && bottomRight);
|
||||
if(!handler || !browser || !printInfo || !topLeft || !topCenter || !topRight
|
||||
|| !bottomLeft || !bottomCenter || !bottomRight)
|
||||
if(!handler || !browser || !frame || !printInfo || !topLeft || !topCenter
|
||||
|| !topRight || !bottomLeft || !bottomCenter || !bottomRight)
|
||||
return RV_CONTINUE;
|
||||
|
||||
CefHandlerCppToC::Struct* impl =
|
||||
reinterpret_cast<CefHandlerCppToC::Struct*>(handler);
|
||||
|
||||
CefBrowserCToCpp* bp = new CefBrowserCToCpp(browser);
|
||||
CefRefPtr<CefBrowser> browserPtr(bp);
|
||||
bp->UnderlyingRelease();
|
||||
|
||||
std::wstring urlStr, titleStr;
|
||||
std::wstring topLeftStr, topCenterStr, topRightStr;
|
||||
std::wstring bottomLeftStr, bottomCenterStr, bottomRightStr;
|
||||
@@ -395,10 +309,11 @@ enum cef_retval_t CEF_CALLBACK handler_handle_print_header_footer(
|
||||
if(*bottomRight)
|
||||
bottomRightStr = *bottomRight;
|
||||
|
||||
enum cef_retval_t rv = impl->class_->GetClass()->
|
||||
HandlePrintHeaderFooter(browserPtr, info, urlStr, titleStr,
|
||||
currentPage, maxPages, topLeftStr, topCenterStr, topRightStr,
|
||||
bottomLeftStr, bottomCenterStr, bottomRightStr);
|
||||
enum cef_retval_t rv = CefHandlerCppToC::Get(handler)->
|
||||
HandlePrintHeaderFooter(CefBrowserCToCpp::Wrap(browser),
|
||||
CefFrameCToCpp::Wrap(frame), info, urlStr, titleStr, currentPage,
|
||||
maxPages, topLeftStr, topCenterStr, topRightStr, bottomLeftStr,
|
||||
bottomCenterStr, bottomRightStr);
|
||||
|
||||
transfer_string_contents(topLeftStr, topLeft);
|
||||
transfer_string_contents(topCenterStr, topCenter);
|
||||
@@ -411,76 +326,60 @@ enum cef_retval_t CEF_CALLBACK handler_handle_print_header_footer(
|
||||
}
|
||||
|
||||
enum cef_retval_t CEF_CALLBACK handler_handle_jsalert(
|
||||
struct _cef_handler_t* handler, cef_browser_t* browser,
|
||||
struct _cef_handler_t* handler, cef_browser_t* browser, cef_frame_t* frame,
|
||||
const wchar_t* message)
|
||||
{
|
||||
DCHECK(handler);
|
||||
DCHECK(browser);
|
||||
if(!handler || !browser)
|
||||
DCHECK(frame);
|
||||
if(!handler || !browser || !frame)
|
||||
return RV_CONTINUE;
|
||||
|
||||
CefHandlerCppToC::Struct* impl =
|
||||
reinterpret_cast<CefHandlerCppToC::Struct*>(handler);
|
||||
|
||||
CefBrowserCToCpp* bp = new CefBrowserCToCpp(browser);
|
||||
CefRefPtr<CefBrowser> browserPtr(bp);
|
||||
bp->UnderlyingRelease();
|
||||
|
||||
std::wstring messageStr;
|
||||
if(message)
|
||||
messageStr = message;
|
||||
|
||||
return impl->class_->GetClass()->HandleJSAlert(browserPtr, messageStr);
|
||||
return CefHandlerCppToC::Get(handler)->HandleJSAlert(
|
||||
CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame), messageStr);
|
||||
}
|
||||
|
||||
enum cef_retval_t CEF_CALLBACK handler_handle_jsconfirm(
|
||||
struct _cef_handler_t* handler, cef_browser_t* browser,
|
||||
struct _cef_handler_t* handler, cef_browser_t* browser, cef_frame_t* frame,
|
||||
const wchar_t* message, int* retval)
|
||||
{
|
||||
DCHECK(handler);
|
||||
DCHECK(browser);
|
||||
DCHECK(frame);
|
||||
DCHECK(retval);
|
||||
if(!handler || !browser || !retval)
|
||||
if(!handler || !browser || !retval || !frame)
|
||||
return RV_CONTINUE;
|
||||
|
||||
CefHandlerCppToC::Struct* impl =
|
||||
reinterpret_cast<CefHandlerCppToC::Struct*>(handler);
|
||||
|
||||
CefBrowserCToCpp* bp = new CefBrowserCToCpp(browser);
|
||||
CefRefPtr<CefBrowser> browserPtr(bp);
|
||||
bp->UnderlyingRelease();
|
||||
|
||||
std::wstring messageStr;
|
||||
if(message)
|
||||
messageStr = message;
|
||||
|
||||
bool ret = false;
|
||||
enum cef_retval_t rv = impl->class_->GetClass()->HandleJSConfirm(browserPtr,
|
||||
messageStr, ret);
|
||||
enum cef_retval_t rv = CefHandlerCppToC::Get(handler)->HandleJSConfirm(
|
||||
CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame), messageStr,
|
||||
ret);
|
||||
*retval = (ret ? 1 : 0);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
enum cef_retval_t CEF_CALLBACK handler_handle_jsprompt(
|
||||
struct _cef_handler_t* handler, cef_browser_t* browser,
|
||||
struct _cef_handler_t* handler, cef_browser_t* browser, cef_frame_t* frame,
|
||||
const wchar_t* message, const wchar_t* defaultValue, int* retval,
|
||||
cef_string_t* result)
|
||||
{
|
||||
DCHECK(handler);
|
||||
DCHECK(browser);
|
||||
DCHECK(frame);
|
||||
DCHECK(retval);
|
||||
DCHECK(result);
|
||||
if(!handler || !browser || !retval || !result)
|
||||
if(!handler || !browser || !frame || !retval || !result)
|
||||
return RV_CONTINUE;
|
||||
|
||||
CefHandlerCppToC::Struct* impl =
|
||||
reinterpret_cast<CefHandlerCppToC::Struct*>(handler);
|
||||
|
||||
CefBrowserCToCpp* bp = new CefBrowserCToCpp(browser);
|
||||
CefRefPtr<CefBrowser> browserPtr(bp);
|
||||
bp->UnderlyingRelease();
|
||||
|
||||
std::wstring messageStr, defaultValueStr, resultStr;
|
||||
|
||||
if(message)
|
||||
@@ -491,8 +390,9 @@ enum cef_retval_t CEF_CALLBACK handler_handle_jsprompt(
|
||||
resultStr = *result;
|
||||
|
||||
bool ret = false;
|
||||
enum cef_retval_t rv = impl->class_->GetClass()->HandleJSPrompt(
|
||||
browserPtr, messageStr, defaultValueStr, ret, resultStr);
|
||||
enum cef_retval_t rv = CefHandlerCppToC::Get(handler)->HandleJSPrompt(
|
||||
CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame), messageStr,
|
||||
defaultValueStr, ret, resultStr);
|
||||
*retval = (ret ? 1 : 0);
|
||||
|
||||
transfer_string_contents(resultStr, result);
|
||||
@@ -508,14 +408,8 @@ enum cef_retval_t CEF_CALLBACK handler_handle_before_window_close(
|
||||
if(!handler || !browser)
|
||||
return RV_CONTINUE;
|
||||
|
||||
CefHandlerCppToC::Struct* impl =
|
||||
reinterpret_cast<CefHandlerCppToC::Struct*>(handler);
|
||||
|
||||
CefBrowserCToCpp* bp = new CefBrowserCToCpp(browser);
|
||||
CefRefPtr<CefBrowser> browserPtr(bp);
|
||||
bp->UnderlyingRelease();
|
||||
|
||||
return impl->class_->GetClass()->HandleBeforeWindowClose(browserPtr);
|
||||
return CefHandlerCppToC::Get(handler)->HandleBeforeWindowClose(
|
||||
CefBrowserCToCpp::Wrap(browser));
|
||||
}
|
||||
|
||||
enum cef_retval_t CEF_CALLBACK handler_handle_take_focus(
|
||||
@@ -526,20 +420,29 @@ enum cef_retval_t CEF_CALLBACK handler_handle_take_focus(
|
||||
if(!handler || !browser)
|
||||
return RV_CONTINUE;
|
||||
|
||||
CefHandlerCppToC::Struct* impl =
|
||||
reinterpret_cast<CefHandlerCppToC::Struct*>(handler);
|
||||
|
||||
CefBrowserCToCpp* bp = new CefBrowserCToCpp(browser);
|
||||
CefRefPtr<CefBrowser> browserPtr(bp);
|
||||
bp->UnderlyingRelease();
|
||||
|
||||
return impl->class_->GetClass()->
|
||||
HandleTakeFocus(browserPtr, (reverse ? true : false));
|
||||
return CefHandlerCppToC::Get(handler)->HandleTakeFocus(
|
||||
CefBrowserCToCpp::Wrap(browser), (reverse ? true : false));
|
||||
}
|
||||
|
||||
enum cef_retval_t CEF_CALLBACK handler_handle_jsbinding(
|
||||
struct _cef_handler_t* handler, cef_browser_t* browser,
|
||||
cef_frame_t* frame, struct _cef_v8value_t* object)
|
||||
{
|
||||
DCHECK(handler);
|
||||
DCHECK(browser);
|
||||
DCHECK(frame);
|
||||
DCHECK(object);
|
||||
if(!handler || !browser || !frame || !object)
|
||||
return RV_CONTINUE;
|
||||
|
||||
return CefHandlerCppToC::Get(handler)->HandleJSBinding(
|
||||
CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame),
|
||||
CefV8ValueCToCpp::Wrap(object));
|
||||
}
|
||||
|
||||
|
||||
CefHandlerCppToC::CefHandlerCppToC(CefHandler* cls)
|
||||
: CefCppToC<CefHandler, cef_handler_t>(cls)
|
||||
: CefCppToC<CefHandlerCppToC, CefHandler, cef_handler_t>(cls)
|
||||
{
|
||||
struct_.struct_.handle_before_created = handler_handle_before_created;
|
||||
struct_.struct_.handle_after_created = handler_handle_after_created;
|
||||
@@ -562,8 +465,9 @@ CefHandlerCppToC::CefHandlerCppToC(CefHandler* cls)
|
||||
struct_.struct_.handle_before_window_close =
|
||||
handler_handle_before_window_close;
|
||||
struct_.struct_.handle_take_focus = handler_handle_take_focus;
|
||||
struct_.struct_.handle_jsbinding = handler_handle_jsbinding;
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
long CefCppToC<CefHandler, cef_handler_t>::DebugObjCt = 0;
|
||||
long CefCppToC<CefHandlerCppToC, CefHandler, cef_handler_t>::DebugObjCt = 0;
|
||||
#endif
|
||||
|
@@ -16,7 +16,8 @@
|
||||
|
||||
// Wrap a C++ handler class with a C handler structure.
|
||||
// This class may be instantiated and accessed wrapper-side only.
|
||||
class CefHandlerCppToC : public CefCppToC<CefHandler, cef_handler_t>
|
||||
class CefHandlerCppToC
|
||||
: public CefCppToC<CefHandlerCppToC, CefHandler, cef_handler_t>
|
||||
{
|
||||
public:
|
||||
CefHandlerCppToC(CefHandler* cls);
|
||||
|
@@ -1,158 +0,0 @@
|
||||
// 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/jshandler_cpptoc.h"
|
||||
#include "ctocpp/browser_ctocpp.h"
|
||||
#include "ctocpp/variant_ctocpp.h"
|
||||
|
||||
|
||||
bool CEF_CALLBACK jshandler_has_method(struct _cef_jshandler_t* jshandler,
|
||||
cef_browser_t* browser, const wchar_t* name)
|
||||
{
|
||||
DCHECK(jshandler);
|
||||
DCHECK(browser);
|
||||
if(!jshandler || !browser)
|
||||
return RV_CONTINUE;
|
||||
|
||||
CefJSHandlerCppToC::Struct* impl =
|
||||
reinterpret_cast<CefJSHandlerCppToC::Struct*>(jshandler);
|
||||
|
||||
CefBrowserCToCpp* bp = new CefBrowserCToCpp(browser);
|
||||
CefRefPtr<CefBrowser> browserPtr(bp);
|
||||
bp->UnderlyingRelease();
|
||||
|
||||
std::wstring nameStr;
|
||||
if(name)
|
||||
nameStr = name;
|
||||
|
||||
return impl->class_->GetClass()->HasMethod(browserPtr, nameStr);
|
||||
}
|
||||
|
||||
bool CEF_CALLBACK jshandler_has_property(struct _cef_jshandler_t* jshandler,
|
||||
cef_browser_t* browser, const wchar_t* name)
|
||||
{
|
||||
DCHECK(jshandler);
|
||||
DCHECK(browser);
|
||||
if(!jshandler || !browser)
|
||||
return RV_CONTINUE;
|
||||
|
||||
CefJSHandlerCppToC::Struct* impl =
|
||||
reinterpret_cast<CefJSHandlerCppToC::Struct*>(jshandler);
|
||||
|
||||
CefBrowserCToCpp* bp = new CefBrowserCToCpp(browser);
|
||||
CefRefPtr<CefBrowser> browserPtr(bp);
|
||||
bp->UnderlyingRelease();
|
||||
|
||||
std::wstring nameStr;
|
||||
if(name)
|
||||
nameStr = name;
|
||||
|
||||
return impl->class_->GetClass()->HasProperty(browserPtr, nameStr);
|
||||
}
|
||||
|
||||
bool CEF_CALLBACK jshandler_set_property(struct _cef_jshandler_t* jshandler,
|
||||
cef_browser_t* browser, const wchar_t* name,
|
||||
struct _cef_variant_t* value)
|
||||
{
|
||||
DCHECK(jshandler);
|
||||
DCHECK(browser);
|
||||
if(!jshandler || !browser)
|
||||
return RV_CONTINUE;
|
||||
|
||||
CefJSHandlerCppToC::Struct* impl =
|
||||
reinterpret_cast<CefJSHandlerCppToC::Struct*>(jshandler);
|
||||
|
||||
CefBrowserCToCpp* bp = new CefBrowserCToCpp(browser);
|
||||
CefRefPtr<CefBrowser> browserPtr(bp);
|
||||
bp->UnderlyingRelease();
|
||||
|
||||
std::wstring nameStr;
|
||||
if(name)
|
||||
nameStr = name;
|
||||
|
||||
CefVariantCToCpp* vp = new CefVariantCToCpp(value);
|
||||
CefRefPtr<CefVariant> valuePtr(vp);
|
||||
vp->UnderlyingRelease();
|
||||
|
||||
return impl->class_->GetClass()->SetProperty(browserPtr, nameStr, valuePtr);
|
||||
}
|
||||
|
||||
bool CEF_CALLBACK jshandler_get_property(struct _cef_jshandler_t* jshandler,
|
||||
cef_browser_t* browser, const wchar_t* name,
|
||||
struct _cef_variant_t* value)
|
||||
{
|
||||
DCHECK(jshandler);
|
||||
DCHECK(browser);
|
||||
if(!jshandler || !browser)
|
||||
return RV_CONTINUE;
|
||||
|
||||
CefJSHandlerCppToC::Struct* impl =
|
||||
reinterpret_cast<CefJSHandlerCppToC::Struct*>(jshandler);
|
||||
|
||||
CefBrowserCToCpp* bp = new CefBrowserCToCpp(browser);
|
||||
CefRefPtr<CefBrowser> browserPtr(bp);
|
||||
bp->UnderlyingRelease();
|
||||
|
||||
std::wstring nameStr;
|
||||
if(name)
|
||||
nameStr = name;
|
||||
|
||||
CefVariantCToCpp* vp = new CefVariantCToCpp(value);
|
||||
CefRefPtr<CefVariant> valuePtr(vp);
|
||||
vp->UnderlyingRelease();
|
||||
|
||||
return impl->class_->GetClass()->GetProperty(browserPtr, nameStr, valuePtr);
|
||||
}
|
||||
|
||||
bool CEF_CALLBACK jshandler_execute_method(struct _cef_jshandler_t* jshandler,
|
||||
cef_browser_t* browser, const wchar_t* name, size_t numargs,
|
||||
struct _cef_variant_t** args, struct _cef_variant_t* retval)
|
||||
{
|
||||
DCHECK(jshandler);
|
||||
DCHECK(browser);
|
||||
if(!jshandler || !browser)
|
||||
return RV_CONTINUE;
|
||||
|
||||
CefJSHandlerCppToC::Struct* impl =
|
||||
reinterpret_cast<CefJSHandlerCppToC::Struct*>(jshandler);
|
||||
|
||||
CefBrowserCToCpp* bp = new CefBrowserCToCpp(browser);
|
||||
CefRefPtr<CefBrowser> browserPtr(bp);
|
||||
bp->UnderlyingRelease();
|
||||
|
||||
std::wstring nameStr;
|
||||
if(name)
|
||||
nameStr = name;
|
||||
|
||||
CefVariantCToCpp* vp = new CefVariantCToCpp(retval);
|
||||
CefRefPtr<CefVariant> retvalPtr(vp);
|
||||
vp->UnderlyingRelease();
|
||||
|
||||
CefJSHandler::VariantVector vec;
|
||||
for(int i = 0; i < (int)numargs; ++i) {
|
||||
vp = new CefVariantCToCpp(args[i]);
|
||||
CefRefPtr<CefVariant> argPtr(vp);
|
||||
vp->UnderlyingRelease();
|
||||
vec.push_back(argPtr);
|
||||
}
|
||||
|
||||
return impl->class_->GetClass()->ExecuteMethod(browserPtr, nameStr, vec,
|
||||
retvalPtr);
|
||||
}
|
||||
|
||||
|
||||
CefJSHandlerCppToC::CefJSHandlerCppToC(CefJSHandler* cls)
|
||||
: CefCppToC<CefJSHandler, cef_jshandler_t>(cls)
|
||||
{
|
||||
struct_.struct_.has_method = jshandler_has_method;
|
||||
struct_.struct_.has_property = jshandler_has_property;
|
||||
struct_.struct_.set_property = jshandler_set_property;
|
||||
struct_.struct_.get_property = jshandler_get_property;
|
||||
struct_.struct_.execute_method = jshandler_execute_method;
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
long CefCppToC<CefJSHandler, cef_jshandler_t>::DebugObjCt = 0;
|
||||
#endif
|
@@ -13,13 +13,10 @@ cef_string_t CEF_CALLBACK request_get_url(struct _cef_request_t* request)
|
||||
if(!request)
|
||||
return NULL;
|
||||
|
||||
CefRequestCppToC::Struct* impl =
|
||||
reinterpret_cast<CefRequestCppToC::Struct*>(request);
|
||||
|
||||
std::wstring urlStr = impl->class_->GetClass()->GetURL();
|
||||
if(urlStr.empty())
|
||||
return NULL;
|
||||
return cef_string_alloc(urlStr.c_str());
|
||||
std::wstring urlStr = CefRequestCppToC::Get(request)->GetURL();
|
||||
if(!urlStr.empty())
|
||||
return cef_string_alloc(urlStr.c_str());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void CEF_CALLBACK request_set_url(struct _cef_request_t* request,
|
||||
@@ -29,44 +26,10 @@ void CEF_CALLBACK request_set_url(struct _cef_request_t* request,
|
||||
if(!request)
|
||||
return;
|
||||
|
||||
CefRequestCppToC::Struct* impl =
|
||||
reinterpret_cast<CefRequestCppToC::Struct*>(request);
|
||||
|
||||
std::wstring urlStr;
|
||||
if(url)
|
||||
urlStr = url;
|
||||
impl->class_->GetClass()->SetURL(urlStr);
|
||||
}
|
||||
|
||||
cef_string_t CEF_CALLBACK request_get_frame(struct _cef_request_t* request)
|
||||
{
|
||||
DCHECK(request);
|
||||
if(!request)
|
||||
return NULL;
|
||||
|
||||
CefRequestCppToC::Struct* impl =
|
||||
reinterpret_cast<CefRequestCppToC::Struct*>(request);
|
||||
|
||||
std::wstring frameStr = impl->class_->GetClass()->GetFrame();
|
||||
if(frameStr.empty())
|
||||
return NULL;
|
||||
return cef_string_alloc(frameStr.c_str());
|
||||
}
|
||||
|
||||
void CEF_CALLBACK request_set_frame(struct _cef_request_t* request,
|
||||
const wchar_t* frame)
|
||||
{
|
||||
DCHECK(request);
|
||||
if(!request)
|
||||
return;
|
||||
|
||||
CefRequestCppToC::Struct* impl =
|
||||
reinterpret_cast<CefRequestCppToC::Struct*>(request);
|
||||
|
||||
std::wstring frameStr;
|
||||
if(frame)
|
||||
frameStr = frame;
|
||||
impl->class_->GetClass()->SetFrame(frameStr);
|
||||
CefRequestCppToC::Get(request)->SetURL(urlStr);
|
||||
}
|
||||
|
||||
cef_string_t CEF_CALLBACK request_get_method(struct _cef_request_t* request)
|
||||
@@ -75,13 +38,10 @@ cef_string_t CEF_CALLBACK request_get_method(struct _cef_request_t* request)
|
||||
if(!request)
|
||||
return NULL;
|
||||
|
||||
CefRequestCppToC::Struct* impl =
|
||||
reinterpret_cast<CefRequestCppToC::Struct*>(request);
|
||||
|
||||
std::wstring methodStr = impl->class_->GetClass()->GetMethod();
|
||||
if(methodStr.empty())
|
||||
return NULL;
|
||||
return cef_string_alloc(methodStr.c_str());
|
||||
std::wstring methodStr = CefRequestCppToC::Get(request)->GetMethod();
|
||||
if(!methodStr.empty())
|
||||
return cef_string_alloc(methodStr.c_str());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void CEF_CALLBACK request_set_method(struct _cef_request_t* request,
|
||||
@@ -91,13 +51,10 @@ void CEF_CALLBACK request_set_method(struct _cef_request_t* request,
|
||||
if(!request)
|
||||
return;
|
||||
|
||||
CefRequestCppToC::Struct* impl =
|
||||
reinterpret_cast<CefRequestCppToC::Struct*>(request);
|
||||
|
||||
std::wstring methodStr;
|
||||
if(method)
|
||||
methodStr = method;
|
||||
impl->class_->GetClass()->SetMethod(methodStr);
|
||||
CefRequestCppToC::Get(request)->SetMethod(methodStr);
|
||||
}
|
||||
|
||||
struct _cef_post_data_t* CEF_CALLBACK request_get_post_data(
|
||||
@@ -107,17 +64,12 @@ struct _cef_post_data_t* CEF_CALLBACK request_get_post_data(
|
||||
if(!request)
|
||||
return NULL;
|
||||
|
||||
CefRequestCppToC::Struct* impl =
|
||||
reinterpret_cast<CefRequestCppToC::Struct*>(request);
|
||||
|
||||
CefRefPtr<CefPostData> postdata =
|
||||
impl->class_->GetClass()->GetPostData();
|
||||
if(!postdata.get())
|
||||
CefRefPtr<CefPostData> postDataPtr =
|
||||
CefRequestCppToC::Get(request)->GetPostData();
|
||||
if(!postDataPtr.get())
|
||||
return NULL;
|
||||
|
||||
CefPostDataCppToC* rp = new CefPostDataCppToC(postdata);
|
||||
rp->AddRef();
|
||||
return rp->GetStruct();
|
||||
return CefPostDataCppToC::Wrap(postDataPtr);
|
||||
}
|
||||
|
||||
void CEF_CALLBACK request_set_post_data(struct _cef_request_t* request,
|
||||
@@ -127,16 +79,11 @@ void CEF_CALLBACK request_set_post_data(struct _cef_request_t* request,
|
||||
if(!request)
|
||||
return;
|
||||
|
||||
CefRequestCppToC::Struct* impl =
|
||||
reinterpret_cast<CefRequestCppToC::Struct*>(request);
|
||||
CefPostDataCppToC::Struct* postStructPtr =
|
||||
reinterpret_cast<CefPostDataCppToC::Struct*>(postData);
|
||||
|
||||
CefRefPtr<CefPostData> postDataPtr;
|
||||
if(postStructPtr)
|
||||
postDataPtr = postStructPtr->class_->GetClass();
|
||||
if(postData)
|
||||
postDataPtr = CefPostDataCppToC::Unwrap(postData);
|
||||
|
||||
impl->class_->GetClass()->SetPostData(postDataPtr);
|
||||
CefRequestCppToC::Get(request)->SetPostData(postDataPtr);
|
||||
}
|
||||
|
||||
void CEF_CALLBACK request_get_header_map(struct _cef_request_t* request,
|
||||
@@ -146,12 +93,8 @@ void CEF_CALLBACK request_get_header_map(struct _cef_request_t* request,
|
||||
if(!request)
|
||||
return;
|
||||
|
||||
CefRequestCppToC::Struct* impl =
|
||||
reinterpret_cast<CefRequestCppToC::Struct*>(request);
|
||||
|
||||
CefRequest::HeaderMap map;
|
||||
impl->class_->GetClass()->GetHeaderMap(map);
|
||||
|
||||
CefRequestCppToC::Get(request)->GetHeaderMap(map);
|
||||
transfer_string_map_contents(map, headerMap);
|
||||
}
|
||||
|
||||
@@ -162,19 +105,15 @@ void CEF_CALLBACK request_set_header_map(struct _cef_request_t* request,
|
||||
if(!request)
|
||||
return;
|
||||
|
||||
CefRequestCppToC::Struct* impl =
|
||||
reinterpret_cast<CefRequestCppToC::Struct*>(request);
|
||||
|
||||
CefRequest::HeaderMap map;
|
||||
if(headerMap)
|
||||
transfer_string_map_contents(headerMap, map);
|
||||
|
||||
impl->class_->GetClass()->SetHeaderMap(map);
|
||||
CefRequestCppToC::Get(request)->SetHeaderMap(map);
|
||||
}
|
||||
|
||||
void CEF_CALLBACK request_set(struct _cef_request_t* request,
|
||||
const wchar_t* url, const wchar_t* frame,
|
||||
const wchar_t* method,
|
||||
const wchar_t* url, const wchar_t* method,
|
||||
struct _cef_post_data_t* postData,
|
||||
cef_string_map_t headerMap)
|
||||
{
|
||||
@@ -182,37 +121,28 @@ void CEF_CALLBACK request_set(struct _cef_request_t* request,
|
||||
if(!request)
|
||||
return;
|
||||
|
||||
CefRequestCppToC::Struct* impl =
|
||||
reinterpret_cast<CefRequestCppToC::Struct*>(request);
|
||||
CefPostDataCppToC::Struct* postStructPtr =
|
||||
reinterpret_cast<CefPostDataCppToC::Struct*>(postData);
|
||||
|
||||
std::wstring urlStr, frameStr, methodStr;
|
||||
CefRefPtr<CefPostData> postPtr;
|
||||
std::wstring urlStr, methodStr;
|
||||
CefRefPtr<CefPostData> postDataPtr;
|
||||
CefRequest::HeaderMap map;
|
||||
|
||||
if(url)
|
||||
urlStr = url;
|
||||
if(frame)
|
||||
frameStr = frame;
|
||||
if(method)
|
||||
methodStr = method;
|
||||
if(postStructPtr)
|
||||
postPtr = postStructPtr->class_->GetClass();
|
||||
if(postData)
|
||||
postDataPtr = CefPostDataCppToC::Unwrap(postData);
|
||||
if(headerMap)
|
||||
transfer_string_map_contents(headerMap, map);
|
||||
|
||||
impl->class_->GetClass()->Set(urlStr, frameStr, methodStr, postPtr, map);
|
||||
CefRequestCppToC::Get(request)->Set(urlStr, methodStr, postDataPtr, map);
|
||||
}
|
||||
|
||||
|
||||
CefRequestCppToC::CefRequestCppToC(CefRequest* cls)
|
||||
: CefCppToC<CefRequest, cef_request_t>(cls)
|
||||
: CefCppToC<CefRequestCppToC, CefRequest, cef_request_t>(cls)
|
||||
{
|
||||
struct_.struct_.get_url = request_get_url;
|
||||
struct_.struct_.set_url = request_set_url;
|
||||
struct_.struct_.get_frame = request_get_frame;
|
||||
struct_.struct_.set_frame = request_set_frame;
|
||||
struct_.struct_.get_method = request_get_method;
|
||||
struct_.struct_.set_method = request_set_method;
|
||||
struct_.struct_.get_post_data = request_get_post_data;
|
||||
@@ -223,7 +153,7 @@ CefRequestCppToC::CefRequestCppToC(CefRequest* cls)
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
long CefCppToC<CefRequest, cef_request_t>::DebugObjCt = 0;
|
||||
long CefCppToC<CefRequestCppToC, CefRequest, cef_request_t>::DebugObjCt = 0;
|
||||
#endif
|
||||
|
||||
|
||||
@@ -234,9 +164,7 @@ size_t CEF_CALLBACK post_data_get_element_count(
|
||||
if(!postData)
|
||||
return 0;
|
||||
|
||||
CefPostDataCppToC::Struct* impl =
|
||||
reinterpret_cast<CefPostDataCppToC::Struct*>(postData);
|
||||
return impl->class_->GetClass()->GetElementCount();
|
||||
return CefPostDataCppToC::Get(postData)->GetElementCount();
|
||||
}
|
||||
|
||||
struct _cef_post_data_element_t* CEF_CALLBACK post_data_get_element(
|
||||
@@ -246,18 +174,13 @@ struct _cef_post_data_element_t* CEF_CALLBACK post_data_get_element(
|
||||
if(!postData)
|
||||
return NULL;
|
||||
|
||||
CefPostDataCppToC::Struct* impl =
|
||||
reinterpret_cast<CefPostDataCppToC::Struct*>(postData);
|
||||
|
||||
CefPostData::ElementVector elements;
|
||||
impl->class_->GetClass()->GetElements(elements);
|
||||
CefPostDataCppToC::Get(postData)->GetElements(elements);
|
||||
|
||||
if(index < 0 || index >= (int)elements.size())
|
||||
return NULL;
|
||||
|
||||
CefPostDataElementCppToC* rp = new CefPostDataElementCppToC(elements[index]);
|
||||
rp->AddRef();
|
||||
return rp->GetStruct();
|
||||
return CefPostDataElementCppToC::Wrap(elements[index]);
|
||||
}
|
||||
|
||||
int CEF_CALLBACK post_data_remove_element(struct _cef_post_data_t* postData,
|
||||
@@ -268,12 +191,9 @@ int CEF_CALLBACK post_data_remove_element(struct _cef_post_data_t* postData,
|
||||
if(!postData || !element)
|
||||
return 0;
|
||||
|
||||
CefPostDataCppToC::Struct* impl =
|
||||
reinterpret_cast<CefPostDataCppToC::Struct*>(postData);
|
||||
CefPostDataElementCppToC::Struct* structPtr =
|
||||
reinterpret_cast<CefPostDataElementCppToC::Struct*>(element);
|
||||
|
||||
return impl->class_->GetClass()->RemoveElement(structPtr->class_->GetClass());
|
||||
CefRefPtr<CefPostDataElement> postDataElementPtr =
|
||||
CefPostDataElementCppToC::Unwrap(element);
|
||||
return CefPostDataCppToC::Get(postData)->RemoveElement(postDataElementPtr);
|
||||
}
|
||||
|
||||
int CEF_CALLBACK post_data_add_element(struct _cef_post_data_t* postData,
|
||||
@@ -284,12 +204,9 @@ int CEF_CALLBACK post_data_add_element(struct _cef_post_data_t* postData,
|
||||
if(!postData || !element)
|
||||
return 0;
|
||||
|
||||
CefPostDataCppToC::Struct* impl =
|
||||
reinterpret_cast<CefPostDataCppToC::Struct*>(postData);
|
||||
CefPostDataElementCppToC::Struct* structPtr =
|
||||
reinterpret_cast<CefPostDataElementCppToC::Struct*>(element);
|
||||
|
||||
return impl->class_->GetClass()->AddElement(structPtr->class_->GetClass());
|
||||
CefRefPtr<CefPostDataElement> postDataElementPtr =
|
||||
CefPostDataElementCppToC::Unwrap(element);
|
||||
return CefPostDataCppToC::Get(postData)->AddElement(postDataElementPtr);
|
||||
}
|
||||
|
||||
void CEF_CALLBACK post_data_remove_elements(struct _cef_post_data_t* postData)
|
||||
@@ -298,15 +215,12 @@ void CEF_CALLBACK post_data_remove_elements(struct _cef_post_data_t* postData)
|
||||
if(!postData)
|
||||
return;
|
||||
|
||||
CefPostDataCppToC::Struct* impl =
|
||||
reinterpret_cast<CefPostDataCppToC::Struct*>(postData);
|
||||
|
||||
impl->class_->GetClass()->RemoveElements();
|
||||
CefPostDataCppToC::Get(postData)->RemoveElements();
|
||||
}
|
||||
|
||||
|
||||
CefPostDataCppToC::CefPostDataCppToC(CefPostData* cls)
|
||||
: CefCppToC<CefPostData, cef_post_data_t>(cls)
|
||||
: CefCppToC<CefPostDataCppToC, CefPostData, cef_post_data_t>(cls)
|
||||
{
|
||||
struct_.struct_.get_element_count = post_data_get_element_count;
|
||||
struct_.struct_.get_element = post_data_get_element;
|
||||
@@ -316,7 +230,8 @@ CefPostDataCppToC::CefPostDataCppToC(CefPostData* cls)
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
long CefCppToC<CefPostData, cef_post_data_t>::DebugObjCt = 0;
|
||||
long CefCppToC<CefPostDataCppToC, CefPostData, cef_post_data_t>::DebugObjCt
|
||||
= 0;
|
||||
#endif
|
||||
|
||||
|
||||
@@ -327,9 +242,7 @@ void CEF_CALLBACK post_data_element_set_to_empty(
|
||||
if(!postDataElement)
|
||||
return;
|
||||
|
||||
CefPostDataElementCppToC::Struct* impl =
|
||||
reinterpret_cast<CefPostDataElementCppToC::Struct*>(postDataElement);
|
||||
impl->class_->GetClass()->SetToEmpty();
|
||||
CefPostDataElementCppToC::Get(postDataElement)->SetToEmpty();
|
||||
}
|
||||
|
||||
void CEF_CALLBACK post_data_element_set_to_file(
|
||||
@@ -340,13 +253,11 @@ void CEF_CALLBACK post_data_element_set_to_file(
|
||||
if(!postDataElement)
|
||||
return;
|
||||
|
||||
CefPostDataElementCppToC::Struct* impl =
|
||||
reinterpret_cast<CefPostDataElementCppToC::Struct*>(postDataElement);
|
||||
|
||||
std::wstring fileNameStr;
|
||||
if(fileName)
|
||||
fileNameStr = fileName;
|
||||
impl->class_->GetClass()->SetToFile(fileNameStr);
|
||||
|
||||
CefPostDataElementCppToC::Get(postDataElement)->SetToFile(fileNameStr);
|
||||
}
|
||||
|
||||
void CEF_CALLBACK post_data_element_set_to_bytes(
|
||||
@@ -357,9 +268,7 @@ void CEF_CALLBACK post_data_element_set_to_bytes(
|
||||
if(!postDataElement)
|
||||
return;
|
||||
|
||||
CefPostDataElementCppToC::Struct* impl =
|
||||
reinterpret_cast<CefPostDataElementCppToC::Struct*>(postDataElement);
|
||||
impl->class_->GetClass()->SetToBytes(size, bytes);
|
||||
CefPostDataElementCppToC::Get(postDataElement)->SetToBytes(size, bytes);
|
||||
}
|
||||
|
||||
cef_postdataelement_type_t CEF_CALLBACK post_data_element_get_type(
|
||||
@@ -369,9 +278,7 @@ cef_postdataelement_type_t CEF_CALLBACK post_data_element_get_type(
|
||||
if(!postDataElement)
|
||||
return PDE_TYPE_EMPTY;
|
||||
|
||||
CefPostDataElementCppToC::Struct* impl =
|
||||
reinterpret_cast<CefPostDataElementCppToC::Struct*>(postDataElement);
|
||||
return impl->class_->GetClass()->GetType();
|
||||
return CefPostDataElementCppToC::Get(postDataElement)->GetType();
|
||||
}
|
||||
|
||||
cef_string_t CEF_CALLBACK post_data_element_get_file(
|
||||
@@ -381,13 +288,11 @@ cef_string_t CEF_CALLBACK post_data_element_get_file(
|
||||
if(!postDataElement)
|
||||
return NULL;
|
||||
|
||||
CefPostDataElementCppToC::Struct* impl =
|
||||
reinterpret_cast<CefPostDataElementCppToC::Struct*>(postDataElement);
|
||||
|
||||
std::wstring fileNameStr = impl->class_->GetClass()->GetFile();
|
||||
if(fileNameStr.empty())
|
||||
return NULL;
|
||||
return cef_string_alloc(fileNameStr.c_str());
|
||||
std::wstring fileNameStr =
|
||||
CefPostDataElementCppToC::Get(postDataElement)->GetFile();
|
||||
if(!fileNameStr.empty())
|
||||
return cef_string_alloc(fileNameStr.c_str());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
size_t CEF_CALLBACK post_data_element_get_bytes_count(
|
||||
@@ -397,9 +302,7 @@ size_t CEF_CALLBACK post_data_element_get_bytes_count(
|
||||
if(!postDataElement)
|
||||
return 0;
|
||||
|
||||
CefPostDataElementCppToC::Struct* impl =
|
||||
reinterpret_cast<CefPostDataElementCppToC::Struct*>(postDataElement);
|
||||
return impl->class_->GetClass()->GetBytesCount();
|
||||
return CefPostDataElementCppToC::Get(postDataElement)->GetBytesCount();
|
||||
}
|
||||
|
||||
size_t CEF_CALLBACK post_data_element_get_bytes(
|
||||
@@ -410,14 +313,13 @@ size_t CEF_CALLBACK post_data_element_get_bytes(
|
||||
if(!postDataElement)
|
||||
return 0;
|
||||
|
||||
CefPostDataElementCppToC::Struct* impl =
|
||||
reinterpret_cast<CefPostDataElementCppToC::Struct*>(postDataElement);
|
||||
return impl->class_->GetClass()->GetBytes(size, bytes);
|
||||
return CefPostDataElementCppToC::Get(postDataElement)->GetBytes(size, bytes);
|
||||
}
|
||||
|
||||
|
||||
CefPostDataElementCppToC::CefPostDataElementCppToC(CefPostDataElement* cls)
|
||||
: CefCppToC<CefPostDataElement, cef_post_data_element_t>(cls)
|
||||
: CefCppToC<CefPostDataElementCppToC, CefPostDataElement,
|
||||
cef_post_data_element_t>(cls)
|
||||
{
|
||||
struct_.struct_.set_to_empty = post_data_element_set_to_empty;
|
||||
struct_.struct_.set_to_file = post_data_element_set_to_file;
|
||||
@@ -429,5 +331,6 @@ CefPostDataElementCppToC::CefPostDataElementCppToC(CefPostDataElement* cls)
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
long CefCppToC<CefPostDataElement, cef_post_data_element_t>::DebugObjCt = 0;
|
||||
long CefCppToC<CefPostDataElementCppToC, CefPostDataElement,
|
||||
cef_post_data_element_t>::DebugObjCt = 0;
|
||||
#endif
|
||||
|
@@ -16,7 +16,8 @@
|
||||
|
||||
// Wrap a C++ request class with a C request structure.
|
||||
// This class may be instantiated and accessed DLL-side only.
|
||||
class CefRequestCppToC : public CefCppToC<CefRequest, cef_request_t>
|
||||
class CefRequestCppToC
|
||||
: public CefCppToC<CefRequestCppToC, CefRequest, cef_request_t>
|
||||
{
|
||||
public:
|
||||
CefRequestCppToC(CefRequest* cls);
|
||||
@@ -26,7 +27,8 @@ public:
|
||||
|
||||
// Wrap a C++ post data class with a C post data structure.
|
||||
// This class may be instantiated and accessed DLL-side only.
|
||||
class CefPostDataCppToC : public CefCppToC<CefPostData, cef_post_data_t>
|
||||
class CefPostDataCppToC
|
||||
: public CefCppToC<CefPostDataCppToC, CefPostData, cef_post_data_t>
|
||||
{
|
||||
public:
|
||||
CefPostDataCppToC(CefPostData* cls);
|
||||
@@ -38,8 +40,9 @@ class CefPostDataElementCppToC;
|
||||
|
||||
// Wrap a C++ post data element class with a C post data element structure.
|
||||
// This class may be instantiated and accessed DLL-side only.
|
||||
class CefPostDataElementCppToC :
|
||||
public CefCppToC<CefPostDataElement, cef_post_data_element_t>
|
||||
class CefPostDataElementCppToC
|
||||
: public CefCppToC<CefPostDataElementCppToC, CefPostDataElement,
|
||||
cef_post_data_element_t>
|
||||
{
|
||||
public:
|
||||
CefPostDataElementCppToC(CefPostDataElement* cls);
|
||||
|
@@ -13,9 +13,7 @@ size_t CEF_CALLBACK stream_reader_read(struct _cef_stream_reader_t* stream,
|
||||
if(!stream)
|
||||
return 0;
|
||||
|
||||
CefStreamReaderCppToC::Struct* impl =
|
||||
reinterpret_cast<CefStreamReaderCppToC::Struct*>(stream);
|
||||
return impl->class_->GetClass()->Read(ptr, size, n);
|
||||
return CefStreamReaderCppToC::Get(stream)->Read(ptr, size, n);
|
||||
}
|
||||
|
||||
int CEF_CALLBACK stream_reader_seek(struct _cef_stream_reader_t* stream,
|
||||
@@ -25,9 +23,7 @@ int CEF_CALLBACK stream_reader_seek(struct _cef_stream_reader_t* stream,
|
||||
if(!stream)
|
||||
return 0;
|
||||
|
||||
CefStreamReaderCppToC::Struct* impl =
|
||||
reinterpret_cast<CefStreamReaderCppToC::Struct*>(stream);
|
||||
return impl->class_->GetClass()->Seek(offset, whence);
|
||||
return CefStreamReaderCppToC::Get(stream)->Seek(offset, whence);
|
||||
}
|
||||
|
||||
long CEF_CALLBACK stream_reader_tell(struct _cef_stream_reader_t* stream)
|
||||
@@ -36,9 +32,7 @@ long CEF_CALLBACK stream_reader_tell(struct _cef_stream_reader_t* stream)
|
||||
if(!stream)
|
||||
return 0;
|
||||
|
||||
CefStreamReaderCppToC::Struct* impl =
|
||||
reinterpret_cast<CefStreamReaderCppToC::Struct*>(stream);
|
||||
return impl->class_->GetClass()->Tell();
|
||||
return CefStreamReaderCppToC::Get(stream)->Tell();
|
||||
}
|
||||
|
||||
int CEF_CALLBACK stream_reader_eof(struct _cef_stream_reader_t* stream)
|
||||
@@ -47,14 +41,13 @@ int CEF_CALLBACK stream_reader_eof(struct _cef_stream_reader_t* stream)
|
||||
if(!stream)
|
||||
return 0;
|
||||
|
||||
CefStreamReaderCppToC::Struct* impl =
|
||||
reinterpret_cast<CefStreamReaderCppToC::Struct*>(stream);
|
||||
return impl->class_->GetClass()->Eof();
|
||||
return CefStreamReaderCppToC::Get(stream)->Eof();
|
||||
}
|
||||
|
||||
|
||||
CefStreamReaderCppToC::CefStreamReaderCppToC(CefStreamReader* cls)
|
||||
: CefCppToC<CefStreamReader, cef_stream_reader_t>(cls)
|
||||
: CefCppToC<CefStreamReaderCppToC, CefStreamReader,
|
||||
cef_stream_reader_t>(cls)
|
||||
{
|
||||
struct_.struct_.read = stream_reader_read;
|
||||
struct_.struct_.seek = stream_reader_seek;
|
||||
@@ -63,7 +56,8 @@ CefStreamReaderCppToC::CefStreamReaderCppToC(CefStreamReader* cls)
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
long CefCppToC<CefStreamReader, cef_stream_reader_t>::DebugObjCt = 0;
|
||||
long CefCppToC<CefStreamReaderCppToC, CefStreamReader,
|
||||
cef_stream_reader_t>::DebugObjCt = 0;
|
||||
#endif
|
||||
|
||||
|
||||
@@ -74,9 +68,7 @@ size_t CEF_CALLBACK stream_writer_write(struct _cef_stream_writer_t* stream,
|
||||
if(!stream)
|
||||
return 0;
|
||||
|
||||
CefStreamWriterCppToC::Struct* impl =
|
||||
reinterpret_cast<CefStreamWriterCppToC::Struct*>(stream);
|
||||
return impl->class_->GetClass()->Write(ptr, size, n);
|
||||
return CefStreamWriterCppToC::Get(stream)->Write(ptr, size, n);
|
||||
}
|
||||
|
||||
int CEF_CALLBACK stream_writer_seek(struct _cef_stream_writer_t* stream,
|
||||
@@ -86,9 +78,7 @@ int CEF_CALLBACK stream_writer_seek(struct _cef_stream_writer_t* stream,
|
||||
if(!stream)
|
||||
return 0;
|
||||
|
||||
CefStreamWriterCppToC::Struct* impl =
|
||||
reinterpret_cast<CefStreamWriterCppToC::Struct*>(stream);
|
||||
return impl->class_->GetClass()->Seek(offset, whence);
|
||||
return CefStreamWriterCppToC::Get(stream)->Seek(offset, whence);
|
||||
}
|
||||
|
||||
long CEF_CALLBACK stream_writer_tell(struct _cef_stream_writer_t* stream)
|
||||
@@ -97,9 +87,7 @@ long CEF_CALLBACK stream_writer_tell(struct _cef_stream_writer_t* stream)
|
||||
if(!stream)
|
||||
return 0;
|
||||
|
||||
CefStreamWriterCppToC::Struct* impl =
|
||||
reinterpret_cast<CefStreamWriterCppToC::Struct*>(stream);
|
||||
return impl->class_->GetClass()->Tell();
|
||||
return CefStreamWriterCppToC::Get(stream)->Tell();
|
||||
}
|
||||
|
||||
int CEF_CALLBACK stream_writer_flush(struct _cef_stream_writer_t* stream)
|
||||
@@ -108,14 +96,13 @@ int CEF_CALLBACK stream_writer_flush(struct _cef_stream_writer_t* stream)
|
||||
if(!stream)
|
||||
return 0;
|
||||
|
||||
CefStreamWriterCppToC::Struct* impl =
|
||||
reinterpret_cast<CefStreamWriterCppToC::Struct*>(stream);
|
||||
return impl->class_->GetClass()->Flush();
|
||||
return CefStreamWriterCppToC::Get(stream)->Flush();
|
||||
}
|
||||
|
||||
|
||||
CefStreamWriterCppToC::CefStreamWriterCppToC(CefStreamWriter* cls)
|
||||
: CefCppToC<CefStreamWriter, cef_stream_writer_t>(cls)
|
||||
: CefCppToC<CefStreamWriterCppToC, CefStreamWriter,
|
||||
cef_stream_writer_t>(cls)
|
||||
{
|
||||
struct_.struct_.write = stream_writer_write;
|
||||
struct_.struct_.seek = stream_writer_seek;
|
||||
@@ -124,5 +111,6 @@ CefStreamWriterCppToC::CefStreamWriterCppToC(CefStreamWriter* cls)
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
long CefCppToC<CefStreamWriter, cef_stream_writer_t>::DebugObjCt = 0;
|
||||
long CefCppToC<CefStreamWriterCppToC, CefStreamWriter,
|
||||
cef_stream_writer_t>::DebugObjCt = 0;
|
||||
#endif
|
||||
|
@@ -16,8 +16,9 @@
|
||||
|
||||
// Wrap a C++ stream reader class with a C stream reader structure.
|
||||
// This class may be instantiated and accessed DLL-side only.
|
||||
class CefStreamReaderCppToC :
|
||||
public CefCppToC<CefStreamReader, cef_stream_reader_t>
|
||||
class CefStreamReaderCppToC
|
||||
: public CefCppToC<CefStreamReaderCppToC, CefStreamReader,
|
||||
cef_stream_reader_t>
|
||||
{
|
||||
public:
|
||||
CefStreamReaderCppToC(CefStreamReader* cls);
|
||||
@@ -27,8 +28,9 @@ public:
|
||||
|
||||
// Wrap a C++ stream writer class with a C stream writer structure.
|
||||
// This class may be instantiated and accessed DLL-side only.
|
||||
class CefStreamWriterCppToC :
|
||||
public CefCppToC<CefStreamWriter, cef_stream_writer_t>
|
||||
class CefStreamWriterCppToC
|
||||
: public CefCppToC<CefStreamWriterCppToC, CefStreamWriter,
|
||||
cef_stream_writer_t>
|
||||
{
|
||||
public:
|
||||
CefStreamWriterCppToC(CefStreamWriter* cls);
|
||||
|
54
libcef_dll/cpptoc/v8handler_cpptoc.cc
Normal file
54
libcef_dll/cpptoc/v8handler_cpptoc.cc
Normal file
@@ -0,0 +1,54 @@
|
||||
// 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
|
@@ -2,8 +2,8 @@
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
|
||||
#ifndef _JSHANDLER_CPPTOC_H
|
||||
#define _JSHANDLER_CPPTOC_H
|
||||
#ifndef _V8HANDLER_CPPTOC_H
|
||||
#define _V8HANDLER_CPPTOC_H
|
||||
|
||||
#ifndef USING_CEF_SHARED
|
||||
#pragma message("Warning: "__FILE__" may be accessed wrapper-side only")
|
||||
@@ -14,15 +14,16 @@
|
||||
#include "cpptoc.h"
|
||||
|
||||
|
||||
// Wrap a C++ jshandler class with a C jshandler structure.
|
||||
// Wrap a C++ v8handler class with a C v8handler structure.
|
||||
// This class may be instantiated and accessed wrapper-side only.
|
||||
class CefJSHandlerCppToC : public CefCppToC<CefJSHandler, cef_jshandler_t>
|
||||
class CefV8HandlerCppToC
|
||||
: public CefCppToC<CefV8HandlerCppToC, CefV8Handler, cef_v8handler_t>
|
||||
{
|
||||
public:
|
||||
CefJSHandlerCppToC(CefJSHandler* cls);
|
||||
virtual ~CefJSHandlerCppToC() {}
|
||||
CefV8HandlerCppToC(CefV8Handler* cls);
|
||||
virtual ~CefV8HandlerCppToC() {}
|
||||
};
|
||||
|
||||
|
||||
#endif // USING_CEF_SHARED
|
||||
#endif // _JSHANDLER_CPPTOC_H
|
||||
#endif // _V8HANDLER_CPPTOC_H
|
359
libcef_dll/cpptoc/v8value_cpptoc.cc
Normal file
359
libcef_dll/cpptoc/v8value_cpptoc.cc
Normal file
@@ -0,0 +1,359 @@
|
||||
// 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/v8value_cpptoc.h"
|
||||
#include "ctocpp/v8handler_ctocpp.h"
|
||||
|
||||
|
||||
int CEF_CALLBACK v8value_is_undefined(struct _cef_v8value_t* v8value)
|
||||
{
|
||||
DCHECK(v8value);
|
||||
if(!v8value)
|
||||
return 0;
|
||||
|
||||
return CefV8ValueCppToC::Get(v8value)->IsUndefined();
|
||||
}
|
||||
|
||||
int CEF_CALLBACK v8value_is_null(struct _cef_v8value_t* v8value)
|
||||
{
|
||||
DCHECK(v8value);
|
||||
if(!v8value)
|
||||
return 0;
|
||||
|
||||
return CefV8ValueCppToC::Get(v8value)->IsNull();
|
||||
}
|
||||
|
||||
int CEF_CALLBACK v8value_is_bool(struct _cef_v8value_t* v8value)
|
||||
{
|
||||
DCHECK(v8value);
|
||||
if(!v8value)
|
||||
return 0;
|
||||
|
||||
return CefV8ValueCppToC::Get(v8value)->IsBool();
|
||||
}
|
||||
|
||||
int CEF_CALLBACK v8value_is_int(struct _cef_v8value_t* v8value)
|
||||
{
|
||||
DCHECK(v8value);
|
||||
if(!v8value)
|
||||
return 0;
|
||||
|
||||
return CefV8ValueCppToC::Get(v8value)->IsInt();
|
||||
}
|
||||
|
||||
int CEF_CALLBACK v8value_is_double(struct _cef_v8value_t* v8value)
|
||||
{
|
||||
DCHECK(v8value);
|
||||
if(!v8value)
|
||||
return 0;
|
||||
|
||||
return CefV8ValueCppToC::Get(v8value)->IsDouble();
|
||||
}
|
||||
|
||||
int CEF_CALLBACK v8value_is_string(struct _cef_v8value_t* v8value)
|
||||
{
|
||||
DCHECK(v8value);
|
||||
if(!v8value)
|
||||
return 0;
|
||||
|
||||
return CefV8ValueCppToC::Get(v8value)->IsString();
|
||||
}
|
||||
|
||||
int CEF_CALLBACK v8value_is_object(struct _cef_v8value_t* v8value)
|
||||
{
|
||||
DCHECK(v8value);
|
||||
if(!v8value)
|
||||
return 0;
|
||||
|
||||
return CefV8ValueCppToC::Get(v8value)->IsObject();
|
||||
}
|
||||
|
||||
int CEF_CALLBACK v8value_is_array(struct _cef_v8value_t* v8value)
|
||||
{
|
||||
DCHECK(v8value);
|
||||
if(!v8value)
|
||||
return 0;
|
||||
|
||||
return CefV8ValueCppToC::Get(v8value)->IsArray();
|
||||
}
|
||||
|
||||
int CEF_CALLBACK v8value_is_function(struct _cef_v8value_t* v8value)
|
||||
{
|
||||
DCHECK(v8value);
|
||||
if(!v8value)
|
||||
return 0;
|
||||
|
||||
return CefV8ValueCppToC::Get(v8value)->IsFunction();
|
||||
}
|
||||
|
||||
int CEF_CALLBACK v8value_get_bool_value(struct _cef_v8value_t* v8value)
|
||||
{
|
||||
DCHECK(v8value);
|
||||
if(!v8value)
|
||||
return 0;
|
||||
|
||||
return CefV8ValueCppToC::Get(v8value)->GetBoolValue();
|
||||
}
|
||||
|
||||
int CEF_CALLBACK v8value_get_int_value(struct _cef_v8value_t* v8value)
|
||||
{
|
||||
DCHECK(v8value);
|
||||
if(!v8value)
|
||||
return 0;
|
||||
|
||||
return CefV8ValueCppToC::Get(v8value)->GetIntValue();
|
||||
}
|
||||
|
||||
double CEF_CALLBACK v8value_get_double_value(struct _cef_v8value_t* v8value)
|
||||
{
|
||||
DCHECK(v8value);
|
||||
if(!v8value)
|
||||
return 0;
|
||||
|
||||
return CefV8ValueCppToC::Get(v8value)->GetDoubleValue();
|
||||
}
|
||||
|
||||
cef_string_t CEF_CALLBACK v8value_get_string_value(struct _cef_v8value_t* v8value)
|
||||
{
|
||||
DCHECK(v8value);
|
||||
if(!v8value)
|
||||
return 0;
|
||||
|
||||
std::wstring valueStr = CefV8ValueCppToC::Get(v8value)->GetStringValue();
|
||||
if(!valueStr.empty())
|
||||
return cef_string_alloc(valueStr.c_str());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int CEF_CALLBACK v8value_has_value_bykey(struct _cef_v8value_t* v8value,
|
||||
const wchar_t* key)
|
||||
{
|
||||
DCHECK(v8value);
|
||||
if(!v8value)
|
||||
return 0;
|
||||
|
||||
std::wstring keyStr;
|
||||
if(key)
|
||||
keyStr = key;
|
||||
|
||||
return CefV8ValueCppToC::Get(v8value)->HasValue(keyStr);
|
||||
}
|
||||
|
||||
int CEF_CALLBACK v8value_has_value_byindex(struct _cef_v8value_t* v8value,
|
||||
int index)
|
||||
{
|
||||
DCHECK(v8value);
|
||||
if(!v8value)
|
||||
return 0;
|
||||
|
||||
return CefV8ValueCppToC::Get(v8value)->HasValue(index);
|
||||
}
|
||||
|
||||
int CEF_CALLBACK v8value_delete_value_bykey(struct _cef_v8value_t* v8value,
|
||||
const wchar_t* key)
|
||||
{
|
||||
DCHECK(v8value);
|
||||
if(!v8value)
|
||||
return 0;
|
||||
|
||||
std::wstring keyStr;
|
||||
if(key)
|
||||
keyStr = key;
|
||||
|
||||
return CefV8ValueCppToC::Get(v8value)->DeleteValue(keyStr);
|
||||
}
|
||||
|
||||
int CEF_CALLBACK v8value_delete_value_byindex(struct _cef_v8value_t* v8value,
|
||||
int index)
|
||||
{
|
||||
DCHECK(v8value);
|
||||
if(!v8value)
|
||||
return 0;
|
||||
|
||||
return CefV8ValueCppToC::Get(v8value)->DeleteValue(index);
|
||||
}
|
||||
|
||||
struct _cef_v8value_t* CEF_CALLBACK v8value_get_value_bykey(
|
||||
struct _cef_v8value_t* v8value, const wchar_t* key)
|
||||
{
|
||||
DCHECK(v8value);
|
||||
if(!v8value)
|
||||
return 0;
|
||||
|
||||
std::wstring keyStr;
|
||||
if(key)
|
||||
keyStr = key;
|
||||
|
||||
CefRefPtr<CefV8Value> valuePtr =
|
||||
CefV8ValueCppToC::Get(v8value)->GetValue(keyStr);
|
||||
return CefV8ValueCppToC::Wrap(valuePtr);
|
||||
}
|
||||
|
||||
struct _cef_v8value_t* CEF_CALLBACK v8value_get_value_byindex(
|
||||
struct _cef_v8value_t* v8value, int index)
|
||||
{
|
||||
DCHECK(v8value);
|
||||
if(!v8value)
|
||||
return 0;
|
||||
|
||||
CefRefPtr<CefV8Value> valuePtr =
|
||||
CefV8ValueCppToC::Get(v8value)->GetValue(index);
|
||||
return CefV8ValueCppToC::Wrap(valuePtr);
|
||||
}
|
||||
|
||||
int CEF_CALLBACK v8value_set_value_bykey(struct _cef_v8value_t* v8value,
|
||||
const wchar_t* key, struct _cef_v8value_t* new_value)
|
||||
{
|
||||
DCHECK(v8value);
|
||||
if(!v8value)
|
||||
return 0;
|
||||
|
||||
std::wstring keyStr;
|
||||
if(key)
|
||||
keyStr = key;
|
||||
|
||||
CefRefPtr<CefV8Value> valuePtr = CefV8ValueCppToC::Unwrap(new_value);
|
||||
return CefV8ValueCppToC::Get(v8value)->SetValue(keyStr, valuePtr);
|
||||
}
|
||||
|
||||
int CEF_CALLBACK v8value_set_value_byindex(struct _cef_v8value_t* v8value,
|
||||
int index, struct _cef_v8value_t* new_value)
|
||||
{
|
||||
DCHECK(v8value);
|
||||
if(!v8value)
|
||||
return 0;
|
||||
|
||||
CefRefPtr<CefV8Value> valuePtr = CefV8ValueCppToC::Unwrap(new_value);
|
||||
return CefV8ValueCppToC::Get(v8value)->SetValue(index, valuePtr);
|
||||
}
|
||||
|
||||
int CEF_CALLBACK v8value_get_keys(struct _cef_v8value_t* v8value,
|
||||
cef_string_list_t list)
|
||||
{
|
||||
DCHECK(v8value);
|
||||
if(!v8value)
|
||||
return 0;
|
||||
|
||||
std::vector<std::wstring> keysList;
|
||||
CefV8ValueCppToC::Get(v8value)->GetKeys(keysList);
|
||||
size_t size = keysList.size();
|
||||
for(size_t i = 0; i < size; ++i)
|
||||
cef_string_list_append(list, keysList[i].c_str());
|
||||
return size;
|
||||
}
|
||||
|
||||
struct _cef_base_t* CEF_CALLBACK v8value_get_user_data(
|
||||
struct _cef_v8value_t* v8value)
|
||||
{
|
||||
DCHECK(v8value);
|
||||
if(!v8value)
|
||||
return 0;
|
||||
|
||||
CefRefPtr<CefBase> base = CefV8ValueCppToC::Get(v8value)->GetUserData();
|
||||
if(base.get())
|
||||
return CefBaseCToCpp::Unwrap(base);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int CEF_CALLBACK v8value_get_array_length(struct _cef_v8value_t* v8value)
|
||||
{
|
||||
DCHECK(v8value);
|
||||
if(!v8value)
|
||||
return 0;
|
||||
|
||||
return CefV8ValueCppToC::Get(v8value)->GetArrayLength();
|
||||
}
|
||||
|
||||
cef_string_t CEF_CALLBACK v8value_get_function_name(
|
||||
struct _cef_v8value_t* v8value)
|
||||
{
|
||||
DCHECK(v8value);
|
||||
if(!v8value)
|
||||
return 0;
|
||||
|
||||
std::wstring functionNameStr =
|
||||
CefV8ValueCppToC::Get(v8value)->GetFunctionName();
|
||||
if(!functionNameStr.empty())
|
||||
return cef_string_alloc(functionNameStr.c_str());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct _cef_v8handler_t* CEF_CALLBACK v8value_get_function_handler(
|
||||
struct _cef_v8value_t* v8value)
|
||||
{
|
||||
DCHECK(v8value);
|
||||
if(!v8value)
|
||||
return 0;
|
||||
|
||||
CefRefPtr<CefV8Handler> handlerPtr =
|
||||
CefV8ValueCppToC::Get(v8value)->GetFunctionHandler();
|
||||
if(handlerPtr.get())
|
||||
return CefV8HandlerCToCpp::Unwrap(handlerPtr);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int CEF_CALLBACK v8value_execute_function(struct _cef_v8value_t* v8value,
|
||||
struct _cef_v8value_t* object, size_t numargs,
|
||||
struct _cef_v8value_t** args, struct _cef_v8value_t** retval,
|
||||
cef_string_t* exception)
|
||||
{
|
||||
DCHECK(v8value);
|
||||
DCHECK(object);
|
||||
if(!v8value || !object)
|
||||
return 0;
|
||||
|
||||
CefRefPtr<CefV8Value> objectPtr = CefV8ValueCppToC::Unwrap(object);
|
||||
CefV8ValueList argsList;
|
||||
for(size_t i = 0; i < numargs; i++)
|
||||
argsList.push_back(CefV8ValueCppToC::Unwrap(args[i]));
|
||||
CefRefPtr<CefV8Value> retvalPtr;
|
||||
std::wstring exceptionStr;
|
||||
|
||||
bool rv = CefV8ValueCppToC::Get(v8value)->ExecuteFunction(objectPtr,
|
||||
argsList, retvalPtr, exceptionStr);
|
||||
if(retvalPtr.get() && retval)
|
||||
*retval = CefV8ValueCppToC::Wrap(retvalPtr);
|
||||
if(!exceptionStr.empty() && exception)
|
||||
*exception = cef_string_alloc(exceptionStr.c_str());
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
CefV8ValueCppToC::CefV8ValueCppToC(CefV8Value* cls)
|
||||
: CefCppToC<CefV8ValueCppToC, CefV8Value, cef_v8value_t>(cls)
|
||||
{
|
||||
struct_.struct_.is_undefined = v8value_is_undefined;
|
||||
struct_.struct_.is_null = v8value_is_null;
|
||||
struct_.struct_.is_bool = v8value_is_bool;
|
||||
struct_.struct_.is_int = v8value_is_int;
|
||||
struct_.struct_.is_double = v8value_is_double;
|
||||
struct_.struct_.is_string = v8value_is_string;
|
||||
struct_.struct_.is_object = v8value_is_object;
|
||||
struct_.struct_.is_array = v8value_is_array;
|
||||
struct_.struct_.is_function = v8value_is_function;
|
||||
struct_.struct_.get_bool_value = v8value_get_bool_value;
|
||||
struct_.struct_.get_int_value = v8value_get_int_value;
|
||||
struct_.struct_.get_double_value = v8value_get_double_value;
|
||||
struct_.struct_.get_string_value = v8value_get_string_value;
|
||||
struct_.struct_.has_value_bykey = v8value_has_value_bykey;
|
||||
struct_.struct_.has_value_byindex = v8value_has_value_byindex;
|
||||
struct_.struct_.delete_value_bykey = v8value_delete_value_bykey;
|
||||
struct_.struct_.delete_value_byindex = v8value_delete_value_byindex;
|
||||
struct_.struct_.get_value_bykey = v8value_get_value_bykey;
|
||||
struct_.struct_.get_value_byindex = v8value_get_value_byindex;
|
||||
struct_.struct_.set_value_bykey = v8value_set_value_bykey;
|
||||
struct_.struct_.set_value_byindex = v8value_set_value_byindex;
|
||||
struct_.struct_.get_keys = v8value_get_keys;
|
||||
struct_.struct_.get_user_data = v8value_get_user_data;
|
||||
struct_.struct_.get_array_length = v8value_get_array_length;
|
||||
struct_.struct_.get_function_name = v8value_get_function_name;
|
||||
struct_.struct_.get_function_handler = v8value_get_function_handler;
|
||||
struct_.struct_.execute_function = v8value_execute_function;
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
long CefCppToC<CefV8ValueCppToC, CefV8Value, cef_v8value_t>::DebugObjCt = 0;
|
||||
#endif
|
29
libcef_dll/cpptoc/v8value_cpptoc.h
Normal file
29
libcef_dll/cpptoc/v8value_cpptoc.h
Normal file
@@ -0,0 +1,29 @@
|
||||
// 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.
|
||||
|
||||
#ifndef _V8VALUE_CPPTOC_H
|
||||
#define _V8VALUE_CPPTOC_H
|
||||
|
||||
#ifndef BUILDING_CEF_SHARED
|
||||
#pragma message("Warning: "__FILE__" may be accessed DLL-side only")
|
||||
#else // BUILDING_CEF_SHARED
|
||||
|
||||
#include "cef.h"
|
||||
#include "cef_capi.h"
|
||||
#include "cpptoc.h"
|
||||
|
||||
|
||||
// Wrap a C++ v8value class with a C v8value structure.
|
||||
// This class may be instantiated and accessed wrapper-side only.
|
||||
class CefV8ValueCppToC
|
||||
: public CefCppToC<CefV8ValueCppToC, CefV8Value, cef_v8value_t>
|
||||
{
|
||||
public:
|
||||
CefV8ValueCppToC(CefV8Value* cls);
|
||||
virtual ~CefV8ValueCppToC() {}
|
||||
};
|
||||
|
||||
|
||||
#endif // BUILDING_CEF_SHARED
|
||||
#endif // _V8VALUE_CPPTOC_H
|
@@ -1,310 +0,0 @@
|
||||
// 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/variant_cpptoc.h"
|
||||
|
||||
|
||||
cef_variant_type_t CEF_CALLBACK variant_get_type(struct _cef_variant_t* variant)
|
||||
{
|
||||
DCHECK(variant);
|
||||
if(!variant)
|
||||
return VARIANT_TYPE_NULL;
|
||||
|
||||
CefVariantCppToC::Struct* impl =
|
||||
reinterpret_cast<CefVariantCppToC::Struct*>(variant);
|
||||
return impl->class_->GetClass()->GetType();
|
||||
}
|
||||
|
||||
void CEF_CALLBACK variant_set_null(struct _cef_variant_t* variant)
|
||||
{
|
||||
DCHECK(variant);
|
||||
if(!variant)
|
||||
return;
|
||||
|
||||
CefVariantCppToC::Struct* impl =
|
||||
reinterpret_cast<CefVariantCppToC::Struct*>(variant);
|
||||
impl->class_->GetClass()->SetNull();
|
||||
}
|
||||
|
||||
void CEF_CALLBACK variant_set_bool(struct _cef_variant_t* variant, int val)
|
||||
{
|
||||
DCHECK(variant);
|
||||
if(!variant)
|
||||
return;
|
||||
|
||||
CefVariantCppToC::Struct* impl =
|
||||
reinterpret_cast<CefVariantCppToC::Struct*>(variant);
|
||||
impl->class_->GetClass()->SetBool(val ? true : false);
|
||||
}
|
||||
|
||||
void CEF_CALLBACK variant_set_int(struct _cef_variant_t* variant, int val)
|
||||
{
|
||||
DCHECK(variant);
|
||||
if(!variant)
|
||||
return;
|
||||
|
||||
CefVariantCppToC::Struct* impl =
|
||||
reinterpret_cast<CefVariantCppToC::Struct*>(variant);
|
||||
impl->class_->GetClass()->SetInt(val);
|
||||
}
|
||||
|
||||
void CEF_CALLBACK variant_set_double(struct _cef_variant_t* variant, double val)
|
||||
{
|
||||
DCHECK(variant);
|
||||
if(!variant)
|
||||
return;
|
||||
|
||||
CefVariantCppToC::Struct* impl =
|
||||
reinterpret_cast<CefVariantCppToC::Struct*>(variant);
|
||||
impl->class_->GetClass()->SetDouble(val);
|
||||
}
|
||||
|
||||
void CEF_CALLBACK variant_set_string(struct _cef_variant_t* variant,
|
||||
const wchar_t* val)
|
||||
{
|
||||
DCHECK(variant);
|
||||
if(!variant)
|
||||
return;
|
||||
|
||||
CefVariantCppToC::Struct* impl =
|
||||
reinterpret_cast<CefVariantCppToC::Struct*>(variant);
|
||||
impl->class_->GetClass()->SetString(val);
|
||||
}
|
||||
|
||||
void CEF_CALLBACK variant_set_bool_array(struct _cef_variant_t* variant,
|
||||
size_t count, const int* vals)
|
||||
{
|
||||
DCHECK(variant);
|
||||
if(!variant)
|
||||
return;
|
||||
|
||||
CefVariantCppToC::Struct* impl =
|
||||
reinterpret_cast<CefVariantCppToC::Struct*>(variant);
|
||||
|
||||
std::vector<bool> vec;
|
||||
for(size_t i = 0; i < count; ++i)
|
||||
vec.push_back(vals[i] ? true : false);
|
||||
|
||||
impl->class_->GetClass()->SetBoolArray(vec);
|
||||
}
|
||||
|
||||
void CEF_CALLBACK variant_set_int_array(struct _cef_variant_t* variant,
|
||||
size_t count, const int* vals)
|
||||
{
|
||||
DCHECK(variant);
|
||||
if(!variant)
|
||||
return;
|
||||
|
||||
CefVariantCppToC::Struct* impl =
|
||||
reinterpret_cast<CefVariantCppToC::Struct*>(variant);
|
||||
|
||||
std::vector<int> vec;
|
||||
for(size_t i = 0; i < count; ++i)
|
||||
vec.push_back(vals[i]);
|
||||
|
||||
impl->class_->GetClass()->SetIntArray(vec);
|
||||
}
|
||||
|
||||
void CEF_CALLBACK variant_set_double_array(struct _cef_variant_t* variant,
|
||||
size_t count, const double* vals)
|
||||
{
|
||||
DCHECK(variant);
|
||||
if(!variant)
|
||||
return;
|
||||
|
||||
CefVariantCppToC::Struct* impl =
|
||||
reinterpret_cast<CefVariantCppToC::Struct*>(variant);
|
||||
|
||||
std::vector<double> vec;
|
||||
for(size_t i = 0; i < count; ++i)
|
||||
vec.push_back(vals[i]);
|
||||
|
||||
impl->class_->GetClass()->SetDoubleArray(vec);
|
||||
}
|
||||
|
||||
void CEF_CALLBACK variant_set_string_array(struct _cef_variant_t* variant,
|
||||
size_t count,
|
||||
const cef_string_t* vals)
|
||||
{
|
||||
DCHECK(variant);
|
||||
if(!variant)
|
||||
return;
|
||||
|
||||
CefVariantCppToC::Struct* impl =
|
||||
reinterpret_cast<CefVariantCppToC::Struct*>(variant);
|
||||
|
||||
std::vector<std::wstring> vec;
|
||||
for(size_t i = 0; i < count; ++i)
|
||||
vec.push_back(vals[i] ? vals[i] : std::wstring());
|
||||
|
||||
impl->class_->GetClass()->SetStringArray(vec);
|
||||
}
|
||||
|
||||
|
||||
int CEF_CALLBACK variant_get_bool(struct _cef_variant_t* variant)
|
||||
{
|
||||
DCHECK(variant);
|
||||
if(!variant)
|
||||
return 0;
|
||||
|
||||
CefVariantCppToC::Struct* impl =
|
||||
reinterpret_cast<CefVariantCppToC::Struct*>(variant);
|
||||
return impl->class_->GetClass()->GetBool();
|
||||
}
|
||||
|
||||
int CEF_CALLBACK variant_get_int(struct _cef_variant_t* variant)
|
||||
{
|
||||
DCHECK(variant);
|
||||
if(!variant)
|
||||
return 0;
|
||||
|
||||
CefVariantCppToC::Struct* impl =
|
||||
reinterpret_cast<CefVariantCppToC::Struct*>(variant);
|
||||
return impl->class_->GetClass()->GetInt();
|
||||
}
|
||||
|
||||
double CEF_CALLBACK variant_get_double(struct _cef_variant_t* variant)
|
||||
{
|
||||
DCHECK(variant);
|
||||
if(!variant)
|
||||
return 0;
|
||||
|
||||
CefVariantCppToC::Struct* impl =
|
||||
reinterpret_cast<CefVariantCppToC::Struct*>(variant);
|
||||
return impl->class_->GetClass()->GetDouble();
|
||||
}
|
||||
|
||||
cef_string_t CEF_CALLBACK variant_get_string(struct _cef_variant_t* variant)
|
||||
{
|
||||
DCHECK(variant);
|
||||
if(!variant)
|
||||
return NULL;
|
||||
|
||||
CefVariantCppToC::Struct* impl =
|
||||
reinterpret_cast<CefVariantCppToC::Struct*>(variant);
|
||||
|
||||
std::wstring str;
|
||||
str = impl->class_->GetClass()->GetString();
|
||||
if(str.empty())
|
||||
return NULL;
|
||||
return cef_string_alloc(str.c_str());
|
||||
}
|
||||
|
||||
int CEF_CALLBACK variant_get_array_size(struct _cef_variant_t* variant)
|
||||
{
|
||||
DCHECK(variant);
|
||||
if(!variant)
|
||||
return 0;
|
||||
|
||||
CefVariantCppToC::Struct* impl =
|
||||
reinterpret_cast<CefVariantCppToC::Struct*>(variant);
|
||||
return impl->class_->GetClass()->GetArraySize();
|
||||
}
|
||||
|
||||
size_t CEF_CALLBACK variant_get_bool_array(struct _cef_variant_t* variant,
|
||||
size_t maxcount, int* vals)
|
||||
{
|
||||
DCHECK(variant);
|
||||
if(!variant)
|
||||
return 0;
|
||||
|
||||
CefVariantCppToC::Struct* impl =
|
||||
reinterpret_cast<CefVariantCppToC::Struct*>(variant);
|
||||
|
||||
std::vector<bool> vec;
|
||||
impl->class_->GetClass()->GetBoolArray(vec);
|
||||
|
||||
size_t ct = 0;
|
||||
for(; ct < maxcount && ct < vec.size(); ++ct)
|
||||
vals[ct] = vec[ct];
|
||||
return ct;
|
||||
}
|
||||
|
||||
size_t CEF_CALLBACK variant_get_int_array(struct _cef_variant_t* variant,
|
||||
size_t maxcount, int* vals)
|
||||
{
|
||||
DCHECK(variant);
|
||||
if(!variant)
|
||||
return 0;
|
||||
|
||||
CefVariantCppToC::Struct* impl =
|
||||
reinterpret_cast<CefVariantCppToC::Struct*>(variant);
|
||||
|
||||
std::vector<int> vec;
|
||||
impl->class_->GetClass()->GetIntArray(vec);
|
||||
|
||||
size_t ct = 0;
|
||||
for(; ct < maxcount && ct < vec.size(); ++ct)
|
||||
vals[ct] = vec[ct];
|
||||
return ct;
|
||||
}
|
||||
|
||||
size_t CEF_CALLBACK variant_get_double_array(struct _cef_variant_t* variant,
|
||||
size_t maxcount, double* vals)
|
||||
{
|
||||
DCHECK(variant);
|
||||
if(!variant)
|
||||
return 0;
|
||||
|
||||
CefVariantCppToC::Struct* impl =
|
||||
reinterpret_cast<CefVariantCppToC::Struct*>(variant);
|
||||
|
||||
std::vector<double> vec;
|
||||
impl->class_->GetClass()->GetDoubleArray(vec);
|
||||
|
||||
size_t ct = 0;
|
||||
for(; ct < maxcount && ct < vec.size(); ++ct)
|
||||
vals[ct] = vec[ct];
|
||||
return ct;
|
||||
}
|
||||
|
||||
size_t CEF_CALLBACK variant_get_string_array(struct _cef_variant_t* variant,
|
||||
size_t maxcount,
|
||||
cef_string_t* vals)
|
||||
{
|
||||
DCHECK(variant);
|
||||
if(!variant)
|
||||
return 0;
|
||||
|
||||
CefVariantCppToC::Struct* impl =
|
||||
reinterpret_cast<CefVariantCppToC::Struct*>(variant);
|
||||
|
||||
std::vector<std::wstring> vec;
|
||||
impl->class_->GetClass()->GetStringArray(vec);
|
||||
|
||||
size_t ct = 0;
|
||||
for(; ct < maxcount && ct < vec.size(); ++ct)
|
||||
vals[ct] = cef_string_alloc(vec[ct].c_str());
|
||||
return ct;
|
||||
}
|
||||
|
||||
|
||||
CefVariantCppToC::CefVariantCppToC(CefVariant* cls)
|
||||
: CefCppToC<CefVariant, cef_variant_t>(cls)
|
||||
{
|
||||
struct_.struct_.get_type = variant_get_type;
|
||||
struct_.struct_.set_null = variant_set_null;
|
||||
struct_.struct_.set_bool = variant_set_bool;
|
||||
struct_.struct_.set_int = variant_set_int;
|
||||
struct_.struct_.set_double = variant_set_double;
|
||||
struct_.struct_.set_string = variant_set_string;
|
||||
struct_.struct_.set_bool_array = variant_set_bool_array;
|
||||
struct_.struct_.set_int_array = variant_set_int_array;
|
||||
struct_.struct_.set_double_array = variant_set_double_array;
|
||||
struct_.struct_.set_string_array = variant_set_string_array;
|
||||
struct_.struct_.get_bool = variant_get_bool;
|
||||
struct_.struct_.get_int = variant_get_int;
|
||||
struct_.struct_.get_double = variant_get_double;
|
||||
struct_.struct_.get_string = variant_get_string;
|
||||
struct_.struct_.get_array_size = variant_get_array_size;
|
||||
struct_.struct_.get_bool_array = variant_get_bool_array;
|
||||
struct_.struct_.get_int_array = variant_get_int_array;
|
||||
struct_.struct_.get_double_array = variant_get_double_array;
|
||||
struct_.struct_.get_string_array = variant_get_string_array;
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
long CefCppToC<CefVariant, cef_variant_t>::DebugObjCt = 0;
|
||||
#endif
|
@@ -4,10 +4,8 @@
|
||||
|
||||
#include "../precompiled_libcef.h"
|
||||
#include "ctocpp/browser_ctocpp.h"
|
||||
#include "ctocpp/request_ctocpp.h"
|
||||
#include "ctocpp/stream_ctocpp.h"
|
||||
#include "cpptoc/handler_cpptoc.h"
|
||||
#include "cpptoc/jshandler_cpptoc.h"
|
||||
#include "ctocpp/frame_ctocpp.h"
|
||||
|
||||
|
||||
bool CefBrowserCToCpp::CanGoBack()
|
||||
@@ -58,62 +56,6 @@ void CefBrowserCToCpp::StopLoad()
|
||||
struct_->stop_load(struct_);
|
||||
}
|
||||
|
||||
void CefBrowserCToCpp::Undo(TargetFrame targetFrame)
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, undo))
|
||||
return;
|
||||
|
||||
struct_->undo(struct_, targetFrame);
|
||||
}
|
||||
|
||||
void CefBrowserCToCpp::Redo(TargetFrame targetFrame)
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, redo))
|
||||
return;
|
||||
|
||||
struct_->redo(struct_, targetFrame);
|
||||
}
|
||||
|
||||
void CefBrowserCToCpp::Cut(TargetFrame targetFrame)
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, cut))
|
||||
return;
|
||||
|
||||
struct_->cut(struct_, targetFrame);
|
||||
}
|
||||
|
||||
void CefBrowserCToCpp::Copy(TargetFrame targetFrame)
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, copy))
|
||||
return;
|
||||
|
||||
struct_->copy(struct_, targetFrame);
|
||||
}
|
||||
|
||||
void CefBrowserCToCpp::Paste(TargetFrame targetFrame)
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, paste))
|
||||
return;
|
||||
|
||||
struct_->paste(struct_, targetFrame);
|
||||
}
|
||||
|
||||
void CefBrowserCToCpp::Delete(TargetFrame targetFrame)
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, del))
|
||||
return;
|
||||
|
||||
struct_->del(struct_, targetFrame);
|
||||
}
|
||||
|
||||
void CefBrowserCToCpp::SelectAll(TargetFrame targetFrame)
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, select_all))
|
||||
return;
|
||||
|
||||
struct_->select_all(struct_, targetFrame);
|
||||
}
|
||||
|
||||
void CefBrowserCToCpp::SetFocus(bool enable)
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, set_focus))
|
||||
@@ -122,155 +64,6 @@ void CefBrowserCToCpp::SetFocus(bool enable)
|
||||
struct_->set_focus(struct_, enable);
|
||||
}
|
||||
|
||||
void CefBrowserCToCpp::Print(TargetFrame targetFrame)
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, print))
|
||||
return;
|
||||
|
||||
struct_->print(struct_, targetFrame);
|
||||
}
|
||||
|
||||
void CefBrowserCToCpp::ViewSource(TargetFrame targetFrame)
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, view_source))
|
||||
return;
|
||||
|
||||
struct_->view_source(struct_, targetFrame);
|
||||
}
|
||||
|
||||
std::wstring CefBrowserCToCpp::GetSource(TargetFrame targetFrame)
|
||||
{
|
||||
std::wstring str;
|
||||
if(CEF_MEMBER_MISSING(struct_, get_source))
|
||||
return str;
|
||||
|
||||
cef_string_t cef_str = struct_->get_source(struct_, targetFrame);
|
||||
if(cef_str) {
|
||||
str = cef_str;
|
||||
cef_string_free(cef_str);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
std::wstring CefBrowserCToCpp::GetText(TargetFrame targetFrame)
|
||||
{
|
||||
std::wstring str;
|
||||
if(CEF_MEMBER_MISSING(struct_, get_text))
|
||||
return str;
|
||||
|
||||
cef_string_t cef_str = struct_->get_text(struct_, targetFrame);
|
||||
if(cef_str) {
|
||||
str = cef_str;
|
||||
cef_string_free(cef_str);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
void CefBrowserCToCpp::LoadRequest(CefRefPtr<CefRequest> request)
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, load_request))
|
||||
return;
|
||||
|
||||
CefRequestCToCpp* rp = static_cast<CefRequestCToCpp*>(request.get());
|
||||
rp->UnderlyingAddRef();
|
||||
struct_->load_request(struct_, rp->GetStruct());
|
||||
}
|
||||
|
||||
void CefBrowserCToCpp::LoadURL(const std::wstring& url,
|
||||
const std::wstring& frame)
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, load_url))
|
||||
return;
|
||||
|
||||
struct_->load_url(struct_, url.c_str(), frame.c_str());
|
||||
}
|
||||
|
||||
void CefBrowserCToCpp::LoadString(const std::wstring& string,
|
||||
const std::wstring& url)
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, load_string))
|
||||
return;
|
||||
|
||||
struct_->load_string(struct_, string.c_str(), url.c_str());
|
||||
}
|
||||
|
||||
void CefBrowserCToCpp::LoadStream(CefRefPtr<CefStreamReader> stream,
|
||||
const std::wstring& url)
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, load_stream))
|
||||
return;
|
||||
|
||||
CefStreamReaderCToCpp* sp =
|
||||
static_cast<CefStreamReaderCToCpp*>(stream.get());
|
||||
sp->UnderlyingAddRef();
|
||||
struct_->load_stream(struct_, sp->GetStruct(), url.c_str());
|
||||
}
|
||||
|
||||
void CefBrowserCToCpp::ExecuteJavaScript(const std::wstring& js_code,
|
||||
const std::wstring& script_url,
|
||||
int start_line,
|
||||
TargetFrame targetFrame)
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, execute_javascript))
|
||||
return;
|
||||
|
||||
struct_->execute_javascript(struct_, js_code.c_str(), script_url.c_str(),
|
||||
start_line, targetFrame);
|
||||
}
|
||||
|
||||
bool CefBrowserCToCpp::AddJSHandler(const std::wstring& classname,
|
||||
CefRefPtr<CefJSHandler> handler)
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, add_jshandler))
|
||||
return false;
|
||||
|
||||
CefJSHandlerCppToC* hp = new CefJSHandlerCppToC(handler);
|
||||
hp->AddRef();
|
||||
return struct_->add_jshandler(struct_, classname.c_str(), hp->GetStruct());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CefBrowserCToCpp::HasJSHandler(const std::wstring& classname)
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, has_jshandler))
|
||||
return false;
|
||||
|
||||
return struct_->has_jshandler(struct_, classname.c_str());
|
||||
}
|
||||
|
||||
CefRefPtr<CefJSHandler> CefBrowserCToCpp::GetJSHandler(const std::wstring& classname)
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, get_jshandler))
|
||||
return NULL;
|
||||
|
||||
CefJSHandlerCppToC::Struct* hp =
|
||||
reinterpret_cast<CefJSHandlerCppToC::Struct*>(
|
||||
struct_->get_jshandler(struct_, classname.c_str()));
|
||||
if(hp) {
|
||||
CefRefPtr<CefJSHandler> handlerPtr(hp->class_->GetClass());
|
||||
hp->class_->UnderlyingRelease();
|
||||
return handlerPtr;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool CefBrowserCToCpp::RemoveJSHandler(const std::wstring& classname)
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, remove_jshandler))
|
||||
return false;
|
||||
|
||||
return struct_->remove_jshandler(struct_, classname.c_str());
|
||||
}
|
||||
|
||||
void CefBrowserCToCpp::RemoveAllJSHandlers()
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, remove_all_jshandlers))
|
||||
return;
|
||||
|
||||
struct_->remove_all_jshandlers(struct_);
|
||||
}
|
||||
|
||||
CefWindowHandle CefBrowserCToCpp::GetWindowHandle()
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, get_window_handle))
|
||||
@@ -291,33 +84,69 @@ CefRefPtr<CefHandler> CefBrowserCToCpp::GetHandler()
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, get_handler))
|
||||
return NULL;
|
||||
|
||||
CefHandlerCppToC::Struct* hp =
|
||||
reinterpret_cast<CefHandlerCppToC::Struct*>(
|
||||
struct_->get_handler(struct_));
|
||||
if(hp) {
|
||||
CefRefPtr<CefHandler> handlerPtr(hp->class_->GetClass());
|
||||
hp->class_->UnderlyingRelease();
|
||||
return handlerPtr;
|
||||
}
|
||||
|
||||
cef_handler_t* handlerStruct = struct_->get_handler(struct_);
|
||||
if(handlerStruct)
|
||||
return CefHandlerCppToC::Unwrap(handlerStruct);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
std::wstring CefBrowserCToCpp::GetURL()
|
||||
CefRefPtr<CefFrame> CefBrowserCToCpp::GetMainFrame()
|
||||
{
|
||||
std::wstring str;
|
||||
if(CEF_MEMBER_MISSING(struct_, get_url))
|
||||
return str;
|
||||
if(CEF_MEMBER_MISSING(struct_, get_main_frame))
|
||||
return NULL;
|
||||
|
||||
cef_string_t cef_str = struct_->get_url(struct_);
|
||||
if(cef_str) {
|
||||
str = cef_str;
|
||||
cef_string_free(cef_str);
|
||||
cef_frame_t* frameStruct = struct_->get_main_frame(struct_);
|
||||
if(frameStruct)
|
||||
return CefFrameCToCpp::Wrap(frameStruct);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CefRefPtr<CefFrame> CefBrowserCToCpp::GetFocusedFrame()
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, get_main_frame))
|
||||
return NULL;
|
||||
|
||||
cef_frame_t* frameStruct = struct_->get_focused_frame(struct_);
|
||||
if(frameStruct)
|
||||
return CefFrameCToCpp::Wrap(frameStruct);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CefRefPtr<CefFrame> CefBrowserCToCpp::GetFrame(const std::wstring& name)
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, get_main_frame))
|
||||
return NULL;
|
||||
|
||||
cef_frame_t* frameStruct = struct_->get_frame(struct_, name.c_str());
|
||||
if(frameStruct)
|
||||
return CefFrameCToCpp::Wrap(frameStruct);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void CefBrowserCToCpp::GetFrameNames(std::vector<std::wstring>& names)
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, get_frame_names))
|
||||
return;
|
||||
|
||||
cef_string_list_t list = cef_string_list_alloc();
|
||||
struct_->get_frame_names(struct_, list);
|
||||
|
||||
cef_string_t str;
|
||||
int size = cef_string_list_size(list);
|
||||
for(int i = 0; i < size; ++i) {
|
||||
str = cef_string_list_value(list, i);
|
||||
names.push_back(str);
|
||||
cef_string_free(str);
|
||||
}
|
||||
return str;
|
||||
|
||||
cef_string_list_free(list);
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
long CefCToCpp<CefBrowser, cef_browser_t>::DebugObjCt = 0;
|
||||
long CefCToCpp<CefBrowserCToCpp, CefBrowser, cef_browser_t>::DebugObjCt = 0;
|
||||
#endif
|
||||
|
@@ -16,11 +16,12 @@
|
||||
|
||||
// Wrap a C browser structure with a C++ browser class.
|
||||
// This class may be instantiated and accessed wrapper-side only.
|
||||
class CefBrowserCToCpp : public CefCToCpp<CefBrowser, cef_browser_t>
|
||||
class CefBrowserCToCpp
|
||||
: public CefCToCpp<CefBrowserCToCpp, CefBrowser, cef_browser_t>
|
||||
{
|
||||
public:
|
||||
CefBrowserCToCpp(cef_browser_t* str)
|
||||
: CefCToCpp<CefBrowser, cef_browser_t>(str) {}
|
||||
: CefCToCpp<CefBrowserCToCpp, CefBrowser, cef_browser_t>(str) {}
|
||||
virtual ~CefBrowserCToCpp() {}
|
||||
|
||||
// CefBrowser methods
|
||||
@@ -30,37 +31,14 @@ public:
|
||||
virtual void GoForward();
|
||||
virtual void Reload();
|
||||
virtual void StopLoad();
|
||||
virtual void Undo(TargetFrame targetFrame);
|
||||
virtual void Redo(TargetFrame targetFrame);
|
||||
virtual void Cut(TargetFrame targetFrame);
|
||||
virtual void Copy(TargetFrame targetFrame);
|
||||
virtual void Paste(TargetFrame targetFrame);
|
||||
virtual void Delete(TargetFrame targetFrame);
|
||||
virtual void SelectAll(TargetFrame targetFrame);
|
||||
virtual void SetFocus(bool enable);
|
||||
virtual void Print(TargetFrame targetFrame);
|
||||
virtual void ViewSource(TargetFrame targetFrame);
|
||||
virtual std::wstring GetSource(TargetFrame targetFrame);
|
||||
virtual std::wstring GetText(TargetFrame targetFrame);
|
||||
virtual void LoadRequest(CefRefPtr<CefRequest> request);
|
||||
virtual void LoadURL(const std::wstring& url, const std::wstring& frame);
|
||||
virtual void LoadString(const std::wstring& string,
|
||||
const std::wstring& url);
|
||||
virtual void LoadStream(CefRefPtr<CefStreamReader> stream,
|
||||
const std::wstring& url);
|
||||
virtual void ExecuteJavaScript(const std::wstring& js_code,
|
||||
const std::wstring& script_url,
|
||||
int start_line, TargetFrame targetFrame);
|
||||
virtual bool AddJSHandler(const std::wstring& classname,
|
||||
CefRefPtr<CefJSHandler> handler);
|
||||
virtual bool HasJSHandler(const std::wstring& classname);
|
||||
virtual CefRefPtr<CefJSHandler> GetJSHandler(const std::wstring& classname);
|
||||
virtual bool RemoveJSHandler(const std::wstring& classname);
|
||||
virtual void RemoveAllJSHandlers();
|
||||
virtual CefWindowHandle GetWindowHandle();
|
||||
virtual bool IsPopup();
|
||||
virtual CefRefPtr<CefHandler> GetHandler();
|
||||
virtual std::wstring GetURL();
|
||||
virtual CefRefPtr<CefFrame> GetMainFrame();
|
||||
virtual CefRefPtr<CefFrame> GetFocusedFrame();
|
||||
virtual CefRefPtr<CefFrame> GetFrame(const std::wstring& name);
|
||||
virtual void GetFrameNames(std::vector<std::wstring>& names);
|
||||
};
|
||||
|
||||
|
||||
|
@@ -10,11 +10,41 @@
|
||||
#include "../cef_logging.h"
|
||||
|
||||
|
||||
// Wrap a C structure with a C++ class.
|
||||
template <class ClassName, class StructName>
|
||||
class CefCToCpp : public CefThreadSafeBase<ClassName>
|
||||
// Wrap a C structure with a C++ class. This is used when the implementation
|
||||
// exists on the other side of the DLL boundary but will have methods called on
|
||||
// this side of the DLL boundary.
|
||||
template <class ClassName, class BaseName, class StructName>
|
||||
class CefCToCpp : public CefThreadSafeBase<BaseName>
|
||||
{
|
||||
public:
|
||||
// Use this method to create a wrapper class instance for a structure
|
||||
// received from the other side.
|
||||
static CefRefPtr<BaseName> Wrap(StructName* s)
|
||||
{
|
||||
// Wrap their structure with the CefCToCpp object.
|
||||
ClassName* wrapper = new ClassName(s);
|
||||
// Put the wrapper object in a smart pointer.
|
||||
CefRefPtr<BaseName> wrapperPtr(wrapper);
|
||||
// Release the reference that was added to the CefCppToC wrapper object on
|
||||
// the other side before their structure was passed to us.
|
||||
wrapper->UnderlyingRelease();
|
||||
// Return the smart pointer.
|
||||
return wrapperPtr;
|
||||
}
|
||||
|
||||
// Use this method to retrieve the underlying structure from a wrapper class
|
||||
// instance for return back to the other side.
|
||||
static StructName* Unwrap(CefRefPtr<BaseName> c)
|
||||
{
|
||||
// Cast the object to our wrapper class type.
|
||||
ClassName* wrapper = static_cast<ClassName*>(c.get());
|
||||
// Add a reference to the CefCppToC wrapper object on the other side that
|
||||
// will be released once the structure is received.
|
||||
wrapper->UnderlyingAddRef();
|
||||
// Return their original structure.
|
||||
return wrapper->GetStruct();
|
||||
}
|
||||
|
||||
CefCToCpp(StructName* str)
|
||||
: struct_(str)
|
||||
{
|
||||
@@ -41,12 +71,12 @@ public:
|
||||
virtual int AddRef()
|
||||
{
|
||||
UnderlyingAddRef();
|
||||
return CefThreadSafeBase<ClassName>::AddRef();
|
||||
return CefThreadSafeBase<BaseName>::AddRef();
|
||||
}
|
||||
virtual int Release()
|
||||
{
|
||||
UnderlyingRelease();
|
||||
return CefThreadSafeBase<ClassName>::Release();
|
||||
return CefThreadSafeBase<BaseName>::Release();
|
||||
}
|
||||
|
||||
// Increment/decrement reference counts on only the underlying class.
|
||||
@@ -77,6 +107,87 @@ public:
|
||||
protected:
|
||||
StructName* struct_;
|
||||
};
|
||||
|
||||
// CefCToCpp implementation for CefBase.
|
||||
class CefBaseCToCpp : public CefThreadSafeBase<CefBase>
|
||||
{
|
||||
public:
|
||||
// Use this method to create a wrapper class instance for a structure
|
||||
// received from the other side.
|
||||
static CefRefPtr<CefBase> Wrap(cef_base_t* s)
|
||||
{
|
||||
// Wrap their structure with the CefCToCpp object.
|
||||
CefBaseCToCpp* wrapper = new CefBaseCToCpp(s);
|
||||
// Put the wrapper object in a smart pointer.
|
||||
CefRefPtr<CefBase> wrapperPtr(wrapper);
|
||||
// Release the reference that was added to the CefCppToC wrapper object on
|
||||
// the other side before their structure was passed to us.
|
||||
wrapper->UnderlyingRelease();
|
||||
// Return the smart pointer.
|
||||
return wrapperPtr;
|
||||
}
|
||||
|
||||
// Use this method to retrieve the underlying structure from a wrapper class
|
||||
// instance for return back to the other side.
|
||||
static cef_base_t* Unwrap(CefRefPtr<CefBase> c)
|
||||
{
|
||||
// Cast the object to our wrapper class type.
|
||||
CefBaseCToCpp* wrapper = static_cast<CefBaseCToCpp*>(c.get());
|
||||
// Add a reference to the CefCppToC wrapper object on the other side that
|
||||
// will be released once the structure is received.
|
||||
wrapper->UnderlyingAddRef();
|
||||
// Return their original structure.
|
||||
return wrapper->GetStruct();
|
||||
}
|
||||
|
||||
CefBaseCToCpp(cef_base_t* str)
|
||||
: struct_(str)
|
||||
{
|
||||
DCHECK(str);
|
||||
}
|
||||
virtual ~CefBaseCToCpp() {}
|
||||
|
||||
// If returning the structure across the DLL boundary you should call
|
||||
// UnderlyingAddRef() on this wrapping CefCToCpp object. On the other side of
|
||||
// the DLL boundary, call Release() on the CefCppToC object.
|
||||
cef_base_t* GetStruct() { return struct_; }
|
||||
|
||||
// CefBase methods increment/decrement reference counts on both this object
|
||||
// and the underlying wrapped structure.
|
||||
virtual int AddRef()
|
||||
{
|
||||
UnderlyingAddRef();
|
||||
return CefThreadSafeBase<CefBase>::AddRef();
|
||||
}
|
||||
virtual int Release()
|
||||
{
|
||||
UnderlyingRelease();
|
||||
return CefThreadSafeBase<CefBase>::Release();
|
||||
}
|
||||
|
||||
// Increment/decrement reference counts on only the underlying class.
|
||||
int UnderlyingAddRef()
|
||||
{
|
||||
if(!struct_->add_ref)
|
||||
return 0;
|
||||
return struct_->add_ref(struct_);
|
||||
}
|
||||
int UnderlyingRelease()
|
||||
{
|
||||
if(!struct_->release)
|
||||
return 0;
|
||||
return struct_->release(struct_);
|
||||
}
|
||||
int UnderlyingGetRefCt()
|
||||
{
|
||||
if(!struct_->get_refct)
|
||||
return 0;
|
||||
return struct_->get_refct(struct_);
|
||||
}
|
||||
|
||||
protected:
|
||||
cef_base_t* struct_;
|
||||
};
|
||||
|
||||
|
||||
#endif // _CTOCPP_H
|
||||
|
203
libcef_dll/ctocpp/frame_ctocpp.cc
Normal file
203
libcef_dll/ctocpp/frame_ctocpp.cc
Normal file
@@ -0,0 +1,203 @@
|
||||
// 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 "ctocpp/frame_ctocpp.h"
|
||||
#include "ctocpp/request_ctocpp.h"
|
||||
#include "ctocpp/stream_ctocpp.h"
|
||||
|
||||
|
||||
void CefFrameCToCpp::Undo()
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, undo))
|
||||
return;
|
||||
|
||||
struct_->undo(struct_);
|
||||
}
|
||||
|
||||
void CefFrameCToCpp::Redo()
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, redo))
|
||||
return;
|
||||
|
||||
struct_->redo(struct_);
|
||||
}
|
||||
|
||||
void CefFrameCToCpp::Cut()
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, cut))
|
||||
return;
|
||||
|
||||
struct_->cut(struct_);
|
||||
}
|
||||
|
||||
void CefFrameCToCpp::Copy()
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, copy))
|
||||
return;
|
||||
|
||||
struct_->copy(struct_);
|
||||
}
|
||||
|
||||
void CefFrameCToCpp::Paste()
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, paste))
|
||||
return;
|
||||
|
||||
struct_->paste(struct_);
|
||||
}
|
||||
|
||||
void CefFrameCToCpp::Delete()
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, del))
|
||||
return;
|
||||
|
||||
struct_->del(struct_);
|
||||
}
|
||||
|
||||
void CefFrameCToCpp::SelectAll()
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, select_all))
|
||||
return;
|
||||
|
||||
struct_->select_all(struct_);
|
||||
}
|
||||
|
||||
void CefFrameCToCpp::Print()
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, print))
|
||||
return;
|
||||
|
||||
struct_->print(struct_);
|
||||
}
|
||||
|
||||
void CefFrameCToCpp::ViewSource()
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, view_source))
|
||||
return;
|
||||
|
||||
struct_->view_source(struct_);
|
||||
}
|
||||
|
||||
std::wstring CefFrameCToCpp::GetSource()
|
||||
{
|
||||
std::wstring str;
|
||||
if(CEF_MEMBER_MISSING(struct_, get_source))
|
||||
return str;
|
||||
|
||||
cef_string_t cef_str = struct_->get_source(struct_);
|
||||
if(cef_str) {
|
||||
str = cef_str;
|
||||
cef_string_free(cef_str);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
std::wstring CefFrameCToCpp::GetText()
|
||||
{
|
||||
std::wstring str;
|
||||
if(CEF_MEMBER_MISSING(struct_, get_text))
|
||||
return str;
|
||||
|
||||
cef_string_t cef_str = struct_->get_text(struct_);
|
||||
if(cef_str) {
|
||||
str = cef_str;
|
||||
cef_string_free(cef_str);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
void CefFrameCToCpp::LoadRequest(CefRefPtr<CefRequest> request)
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, load_request))
|
||||
return;
|
||||
|
||||
struct_->load_request(struct_, CefRequestCToCpp::Unwrap(request));
|
||||
}
|
||||
|
||||
void CefFrameCToCpp::LoadURL(const std::wstring& url)
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, load_url))
|
||||
return;
|
||||
|
||||
struct_->load_url(struct_, url.c_str());
|
||||
}
|
||||
|
||||
void CefFrameCToCpp::LoadString(const std::wstring& string,
|
||||
const std::wstring& url)
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, load_string))
|
||||
return;
|
||||
|
||||
struct_->load_string(struct_, string.c_str(), url.c_str());
|
||||
}
|
||||
|
||||
void CefFrameCToCpp::LoadStream(CefRefPtr<CefStreamReader> stream,
|
||||
const std::wstring& url)
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, load_stream))
|
||||
return;
|
||||
|
||||
struct_->load_stream(struct_, CefStreamReaderCToCpp::Unwrap(stream),
|
||||
url.c_str());
|
||||
}
|
||||
|
||||
void CefFrameCToCpp::ExecuteJavaScript(const std::wstring& js_code,
|
||||
const std::wstring& script_url,
|
||||
int start_line)
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, execute_javascript))
|
||||
return;
|
||||
|
||||
struct_->execute_javascript(struct_, js_code.c_str(), script_url.c_str(),
|
||||
start_line);
|
||||
}
|
||||
|
||||
bool CefFrameCToCpp::IsMain()
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, is_main))
|
||||
return false;
|
||||
|
||||
return struct_->is_main(struct_);
|
||||
}
|
||||
|
||||
bool CefFrameCToCpp::IsFocused()
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, is_focused))
|
||||
return false;
|
||||
|
||||
return struct_->is_focused(struct_);
|
||||
}
|
||||
|
||||
std::wstring CefFrameCToCpp::GetName()
|
||||
{
|
||||
std::wstring str;
|
||||
if(CEF_MEMBER_MISSING(struct_, get_name))
|
||||
return str;
|
||||
|
||||
cef_string_t cef_str = struct_->get_name(struct_);
|
||||
if(cef_str) {
|
||||
str = cef_str;
|
||||
cef_string_free(cef_str);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
std::wstring CefFrameCToCpp::GetURL()
|
||||
{
|
||||
std::wstring str;
|
||||
if(CEF_MEMBER_MISSING(struct_, get_url))
|
||||
return str;
|
||||
|
||||
cef_string_t cef_str = struct_->get_url(struct_);
|
||||
if(cef_str) {
|
||||
str = cef_str;
|
||||
cef_string_free(cef_str);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
long CefCToCpp<CefFrameCToCpp, CefFrame, cef_frame_t>::DebugObjCt = 0;
|
||||
#endif
|
55
libcef_dll/ctocpp/frame_ctocpp.h
Normal file
55
libcef_dll/ctocpp/frame_ctocpp.h
Normal file
@@ -0,0 +1,55 @@
|
||||
// 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.
|
||||
|
||||
#ifndef _FRAME_CTOCPP_H
|
||||
#define _FRAME_CTOCPP_H
|
||||
|
||||
#ifndef USING_CEF_SHARED
|
||||
#pragma message("Warning: "__FILE__" may be accessed wrapper-side only")
|
||||
#else // USING_CEF_SHARED
|
||||
|
||||
#include "cef.h"
|
||||
#include "cef_capi.h"
|
||||
#include "ctocpp.h"
|
||||
|
||||
|
||||
// Wrap a C frame structure with a C++ frame class.
|
||||
// This class may be instantiated and accessed wrapper-side only.
|
||||
class CefFrameCToCpp : public CefCToCpp<CefFrameCToCpp, CefFrame, cef_frame_t>
|
||||
{
|
||||
public:
|
||||
CefFrameCToCpp(cef_frame_t* str)
|
||||
: CefCToCpp<CefFrameCToCpp, CefFrame, cef_frame_t>(str) {}
|
||||
virtual ~CefFrameCToCpp() {}
|
||||
|
||||
// CefFrame methods
|
||||
virtual void Undo();
|
||||
virtual void Redo();
|
||||
virtual void Cut();
|
||||
virtual void Copy();
|
||||
virtual void Paste();
|
||||
virtual void Delete();
|
||||
virtual void SelectAll();
|
||||
virtual void Print();
|
||||
virtual void ViewSource();
|
||||
virtual std::wstring GetSource();
|
||||
virtual std::wstring GetText();
|
||||
virtual void LoadRequest(CefRefPtr<CefRequest> request);
|
||||
virtual void LoadURL(const std::wstring& url);
|
||||
virtual void LoadString(const std::wstring& string,
|
||||
const std::wstring& url);
|
||||
virtual void LoadStream(CefRefPtr<CefStreamReader> stream,
|
||||
const std::wstring& url);
|
||||
virtual void ExecuteJavaScript(const std::wstring& jsCode,
|
||||
const std::wstring& scriptUrl,
|
||||
int startLine);
|
||||
virtual bool IsMain();
|
||||
virtual bool IsFocused();
|
||||
virtual std::wstring GetName();
|
||||
virtual std::wstring GetURL();
|
||||
};
|
||||
|
||||
|
||||
#endif // USING_CEF_SHARED
|
||||
#endif // _FRAME_CTOCPP_H
|
@@ -4,8 +4,10 @@
|
||||
|
||||
#include "../precompiled_libcef.h"
|
||||
#include "cpptoc/browser_cpptoc.h"
|
||||
#include "cpptoc/frame_cpptoc.h"
|
||||
#include "cpptoc/request_cpptoc.h"
|
||||
#include "cpptoc/stream_cpptoc.h"
|
||||
#include "cpptoc/v8value_cpptoc.h"
|
||||
#include "ctocpp/handler_ctocpp.h"
|
||||
#include "transfer_util.h"
|
||||
|
||||
@@ -17,38 +19,28 @@ CefHandler::RetVal CefHandlerCToCpp::HandleBeforeCreated(
|
||||
if(CEF_MEMBER_MISSING(struct_, handle_before_created))
|
||||
return RV_CONTINUE;
|
||||
|
||||
CefBrowserCppToC* browserPtr = NULL;
|
||||
cef_browser_t* browserStructPtr = NULL;
|
||||
if(parentBrowser.get()) {
|
||||
browserPtr = new CefBrowserCppToC(parentBrowser);
|
||||
browserPtr->AddRef();
|
||||
browserStructPtr = browserPtr->GetStruct();
|
||||
}
|
||||
cef_browser_t* browserStruct = NULL;
|
||||
if(parentBrowser.get())
|
||||
browserStruct = CefBrowserCppToC::Wrap(parentBrowser);
|
||||
|
||||
CefHandlerCToCpp* handlerPtr = NULL;
|
||||
cef_handler_t* handlerRet = NULL;
|
||||
if(handler.get()) {
|
||||
handlerPtr = static_cast<CefHandlerCToCpp*>(handler.get());
|
||||
handlerPtr->UnderlyingAddRef();
|
||||
handlerRet = handlerPtr->GetStruct();
|
||||
}
|
||||
cef_handler_t* handlerStruct = NULL;
|
||||
if(handler.get())
|
||||
handlerStruct = CefHandlerCToCpp::Unwrap(handler);
|
||||
cef_handler_t *origHandlerStruct = handlerStruct;
|
||||
|
||||
cef_string_t urlRet = NULL;
|
||||
if(!url.empty())
|
||||
urlRet = cef_string_alloc(url.c_str());
|
||||
|
||||
cef_retval_t rv = struct_->handle_before_created(struct_,
|
||||
browserStructPtr, &windowInfo, popup, &handlerRet, &urlRet);
|
||||
browserStruct, &windowInfo, popup, &handlerStruct, &urlRet);
|
||||
|
||||
if(handlerPtr && handlerRet != handlerPtr->GetStruct()) {
|
||||
if(handlerStruct && handlerStruct != origHandlerStruct) {
|
||||
// The handler was changed.
|
||||
if(handlerRet) {
|
||||
CefHandlerCToCpp* hp = new CefHandlerCToCpp(handlerRet);
|
||||
handler = hp;
|
||||
hp->UnderlyingRelease();
|
||||
} else {
|
||||
if(handlerStruct)
|
||||
handler = CefHandlerCToCpp::Wrap(handlerStruct);
|
||||
else
|
||||
handler = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
transfer_string_contents(urlRet, url, true);
|
||||
@@ -62,20 +54,19 @@ CefHandler::RetVal CefHandlerCToCpp::HandleAfterCreated(
|
||||
if(CEF_MEMBER_MISSING(struct_, handle_after_created))
|
||||
return RV_CONTINUE;
|
||||
|
||||
CefBrowserCppToC* browserPtr = new CefBrowserCppToC(browser);
|
||||
browserPtr->AddRef();
|
||||
return struct_->handle_after_created(struct_, browserPtr->GetStruct());
|
||||
return struct_->handle_after_created(struct_,
|
||||
CefBrowserCppToC::Wrap(browser));
|
||||
}
|
||||
|
||||
CefHandler::RetVal CefHandlerCToCpp::HandleAddressChange(
|
||||
CefRefPtr<CefBrowser> browser, const std::wstring& url)
|
||||
CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame,
|
||||
const std::wstring& url)
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, handle_address_change))
|
||||
return RV_CONTINUE;
|
||||
|
||||
CefBrowserCppToC* browserPtr = new CefBrowserCppToC(browser);
|
||||
browserPtr->AddRef();
|
||||
return struct_->handle_address_change(struct_, browserPtr->GetStruct(),
|
||||
return struct_->handle_address_change(struct_,
|
||||
CefBrowserCppToC::Wrap(browser), CefFrameCppToC::Wrap(frame),
|
||||
url.c_str());
|
||||
}
|
||||
|
||||
@@ -85,69 +76,64 @@ CefHandler::RetVal CefHandlerCToCpp::HandleTitleChange(
|
||||
if(CEF_MEMBER_MISSING(struct_, handle_title_change))
|
||||
return RV_CONTINUE;
|
||||
|
||||
CefBrowserCppToC* browserPtr = new CefBrowserCppToC(browser);
|
||||
browserPtr->AddRef();
|
||||
return struct_->handle_title_change(struct_, browserPtr->GetStruct(),
|
||||
return struct_->handle_title_change(struct_, CefBrowserCppToC::Wrap(browser),
|
||||
title.c_str());
|
||||
}
|
||||
|
||||
CefHandler::RetVal CefHandlerCToCpp::HandleBeforeBrowse(
|
||||
CefRefPtr<CefBrowser> browser, CefRefPtr<CefRequest> request,
|
||||
NavType navType, bool isRedirect)
|
||||
CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefRequest> request, NavType navType, bool isRedirect)
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, handle_before_browse))
|
||||
return RV_CONTINUE;
|
||||
|
||||
CefBrowserCppToC* browserPtr = new CefBrowserCppToC(browser);
|
||||
browserPtr->AddRef();
|
||||
|
||||
CefRequestCppToC* requestPtr = new CefRequestCppToC(request);
|
||||
requestPtr->AddRef();
|
||||
|
||||
return struct_->handle_before_browse(struct_, browserPtr->GetStruct(),
|
||||
requestPtr->GetStruct(), navType, isRedirect);
|
||||
return struct_->handle_before_browse(struct_, CefBrowserCppToC::Wrap(browser),
|
||||
CefFrameCppToC::Wrap(frame), CefRequestCppToC::Wrap(request),
|
||||
navType, isRedirect);
|
||||
}
|
||||
|
||||
CefHandler::RetVal CefHandlerCToCpp::HandleLoadStart(
|
||||
CefRefPtr<CefBrowser> browser)
|
||||
CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame)
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, handle_load_start))
|
||||
return RV_CONTINUE;
|
||||
|
||||
CefBrowserCppToC* browserPtr = new CefBrowserCppToC(browser);
|
||||
browserPtr->AddRef();
|
||||
cef_frame_t* frameStruct = NULL;
|
||||
if(frame.get())
|
||||
frameStruct = CefFrameCppToC::Wrap(frame);
|
||||
|
||||
return struct_->handle_load_start(struct_, browserPtr->GetStruct());
|
||||
return struct_->handle_load_start(struct_, CefBrowserCppToC::Wrap(browser),
|
||||
frameStruct);
|
||||
}
|
||||
|
||||
CefHandler::RetVal CefHandlerCToCpp::HandleLoadEnd(
|
||||
CefRefPtr<CefBrowser> browser)
|
||||
CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame)
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, handle_load_end))
|
||||
return RV_CONTINUE;
|
||||
|
||||
CefBrowserCppToC* browserPtr = new CefBrowserCppToC(browser);
|
||||
browserPtr->AddRef();
|
||||
cef_frame_t* frameStruct = NULL;
|
||||
if(frame.get())
|
||||
frameStruct = CefFrameCppToC::Wrap(frame);
|
||||
|
||||
return struct_->handle_load_end(struct_, browserPtr->GetStruct());
|
||||
return struct_->handle_load_end(struct_, CefBrowserCppToC::Wrap(browser),
|
||||
frameStruct);
|
||||
}
|
||||
|
||||
CefHandler::RetVal CefHandlerCToCpp::HandleLoadError(
|
||||
CefRefPtr<CefBrowser> browser, ErrorCode errorCode,
|
||||
const std::wstring& failedUrl, std::wstring& errorText)
|
||||
CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame,
|
||||
ErrorCode errorCode, const std::wstring& failedUrl, std::wstring& errorText)
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, handle_load_error))
|
||||
return RV_CONTINUE;
|
||||
|
||||
CefBrowserCppToC* browserPtr = new CefBrowserCppToC(browser);
|
||||
browserPtr->AddRef();
|
||||
|
||||
cef_string_t errorTextRet = NULL;
|
||||
if(!errorText.empty())
|
||||
errorTextRet = cef_string_alloc(errorText.c_str());
|
||||
|
||||
cef_retval_t rv = struct_->handle_load_error(struct_, browserPtr->GetStruct(),
|
||||
errorCode, failedUrl.c_str(), &errorTextRet);
|
||||
cef_retval_t rv = struct_->handle_load_error(struct_,
|
||||
CefBrowserCppToC::Wrap(browser), CefFrameCppToC::Wrap(frame), errorCode,
|
||||
failedUrl.c_str(), &errorTextRet);
|
||||
|
||||
transfer_string_contents(errorTextRet, errorText, true);
|
||||
|
||||
@@ -162,12 +148,6 @@ CefHandler::RetVal CefHandlerCToCpp::HandleBeforeResourceLoad(
|
||||
if(CEF_MEMBER_MISSING(struct_, handle_before_resource_load))
|
||||
return RV_CONTINUE;
|
||||
|
||||
CefBrowserCppToC* browserPtr = new CefBrowserCppToC(browser);
|
||||
browserPtr->AddRef();
|
||||
|
||||
CefRequestCppToC* requestPtr = new CefRequestCppToC(request);
|
||||
requestPtr->AddRef();
|
||||
|
||||
cef_string_t redirectUrlRet = NULL;
|
||||
cef_string_t mimeTypeRet = NULL;
|
||||
cef_stream_reader_t* streamRet = NULL;
|
||||
@@ -176,18 +156,14 @@ CefHandler::RetVal CefHandlerCToCpp::HandleBeforeResourceLoad(
|
||||
redirectUrlRet = cef_string_alloc(redirectUrl.c_str());
|
||||
|
||||
cef_retval_t rv = struct_->handle_before_resource_load(struct_,
|
||||
browserPtr->GetStruct(), requestPtr->GetStruct(), &redirectUrlRet,
|
||||
&streamRet, &mimeTypeRet, loadFlags);
|
||||
CefBrowserCppToC::Wrap(browser), CefRequestCppToC::Wrap(request),
|
||||
&redirectUrlRet, &streamRet, &mimeTypeRet, loadFlags);
|
||||
|
||||
transfer_string_contents(redirectUrlRet, redirectUrl, true);
|
||||
transfer_string_contents(mimeTypeRet, mimeType, true);
|
||||
|
||||
if(streamRet) {
|
||||
CefStreamReaderCppToC::Struct* sp =
|
||||
reinterpret_cast<CefStreamReaderCppToC::Struct*>(streamRet);
|
||||
resourceStream = sp->class_->GetClass();
|
||||
sp->class_->Release();
|
||||
}
|
||||
if(streamRet)
|
||||
resourceStream = CefStreamReaderCppToC::Unwrap(streamRet);
|
||||
|
||||
return rv;
|
||||
}
|
||||
@@ -198,10 +174,7 @@ CefHandler::RetVal CefHandlerCToCpp::HandleBeforeMenu(
|
||||
if(CEF_MEMBER_MISSING(struct_, handle_before_menu))
|
||||
return RV_CONTINUE;
|
||||
|
||||
CefBrowserCppToC* browserPtr = new CefBrowserCppToC(browser);
|
||||
browserPtr->AddRef();
|
||||
|
||||
return struct_->handle_before_menu(struct_, browserPtr->GetStruct(),
|
||||
return struct_->handle_before_menu(struct_, CefBrowserCppToC::Wrap(browser),
|
||||
&menuInfo);
|
||||
}
|
||||
|
||||
@@ -211,15 +184,12 @@ CefHandler::RetVal CefHandlerCToCpp::HandleGetMenuLabel(
|
||||
if(CEF_MEMBER_MISSING(struct_, handle_get_menu_label))
|
||||
return RV_CONTINUE;
|
||||
|
||||
CefBrowserCppToC* browserPtr = new CefBrowserCppToC(browser);
|
||||
browserPtr->AddRef();
|
||||
|
||||
cef_string_t labelRet = NULL;
|
||||
if(!label.empty())
|
||||
labelRet = cef_string_alloc(label.c_str());
|
||||
|
||||
cef_retval_t rv = struct_->handle_get_menu_label(struct_,
|
||||
browserPtr->GetStruct(), menuId, &labelRet);
|
||||
CefBrowserCppToC::Wrap(browser), menuId, &labelRet);
|
||||
|
||||
transfer_string_contents(labelRet, label, true);
|
||||
|
||||
@@ -232,25 +202,20 @@ CefHandler::RetVal CefHandlerCToCpp::HandleMenuAction(
|
||||
if(CEF_MEMBER_MISSING(struct_, handle_menu_action))
|
||||
return RV_CONTINUE;
|
||||
|
||||
CefBrowserCppToC* browserPtr = new CefBrowserCppToC(browser);
|
||||
browserPtr->AddRef();
|
||||
|
||||
return struct_->handle_menu_action(struct_, browserPtr->GetStruct(), menuId);
|
||||
return struct_->handle_menu_action(struct_, CefBrowserCppToC::Wrap(browser),
|
||||
menuId);
|
||||
}
|
||||
|
||||
CefHandler::RetVal CefHandlerCToCpp::HandlePrintHeaderFooter(
|
||||
CefRefPtr<CefBrowser> browser, CefPrintInfo& printInfo,
|
||||
const std::wstring& url, const std::wstring& title, int currentPage,
|
||||
int maxPages, std::wstring& topLeft, std::wstring& topCenter,
|
||||
std::wstring& topRight, std::wstring& bottomLeft,
|
||||
CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame,
|
||||
CefPrintInfo& printInfo, const std::wstring& url, const std::wstring& title,
|
||||
int currentPage, int maxPages, std::wstring& topLeft,
|
||||
std::wstring& topCenter, std::wstring& topRight, std::wstring& bottomLeft,
|
||||
std::wstring& bottomCenter, std::wstring& bottomRight)
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, handle_print_header_footer))
|
||||
return RV_CONTINUE;
|
||||
|
||||
CefBrowserCppToC* browserPtr = new CefBrowserCppToC(browser);
|
||||
browserPtr->AddRef();
|
||||
|
||||
cef_string_t topLeftRet = NULL, topCenterRet = NULL, topRightRet = NULL,
|
||||
bottomLeftRet = NULL, bottomCenterRet = NULL, bottomRightRet = NULL;
|
||||
|
||||
@@ -268,9 +233,10 @@ CefHandler::RetVal CefHandlerCToCpp::HandlePrintHeaderFooter(
|
||||
bottomRightRet = cef_string_alloc(bottomRight.c_str());
|
||||
|
||||
cef_retval_t rv = struct_->handle_print_header_footer(struct_,
|
||||
browserPtr->GetStruct(), &printInfo, url.c_str(), title.c_str(),
|
||||
currentPage, maxPages, &topLeftRet, &topCenterRet, &topRightRet,
|
||||
&bottomLeftRet, &bottomCenterRet, &bottomRightRet);
|
||||
CefBrowserCppToC::Wrap(browser), CefFrameCppToC::Wrap(frame),
|
||||
&printInfo, url.c_str(), title.c_str(), currentPage, maxPages,
|
||||
&topLeftRet, &topCenterRet, &topRightRet, &bottomLeftRet,
|
||||
&bottomCenterRet, &bottomRightRet);
|
||||
|
||||
transfer_string_contents(topLeftRet, topLeft, true);
|
||||
transfer_string_contents(topCenterRet, topCenter, true);
|
||||
@@ -283,50 +249,46 @@ CefHandler::RetVal CefHandlerCToCpp::HandlePrintHeaderFooter(
|
||||
}
|
||||
|
||||
CefHandler::RetVal CefHandlerCToCpp::HandleJSAlert(
|
||||
CefRefPtr<CefBrowser> browser, const std::wstring& message)
|
||||
CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame,
|
||||
const std::wstring& message)
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, handle_jsalert))
|
||||
return RV_CONTINUE;
|
||||
|
||||
CefBrowserCppToC* browserPtr = new CefBrowserCppToC(browser);
|
||||
browserPtr->AddRef();
|
||||
|
||||
return struct_->handle_jsalert(struct_, browserPtr->GetStruct(),
|
||||
message.c_str());
|
||||
return struct_->handle_jsalert(struct_, CefBrowserCppToC::Wrap(browser),
|
||||
CefFrameCppToC::Wrap(frame), message.c_str());
|
||||
}
|
||||
|
||||
CefHandler::RetVal CefHandlerCToCpp::HandleJSConfirm(
|
||||
CefRefPtr<CefBrowser> browser, const std::wstring& message, bool& retval)
|
||||
CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame,
|
||||
const std::wstring& message, bool& retval)
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, handle_jsconfirm))
|
||||
return RV_CONTINUE;
|
||||
|
||||
CefBrowserCppToC* browserPtr = new CefBrowserCppToC(browser);
|
||||
browserPtr->AddRef();
|
||||
|
||||
int ret = 0;
|
||||
cef_retval_t rv = struct_->handle_jsconfirm(struct_, browserPtr->GetStruct(),
|
||||
cef_retval_t rv = struct_->handle_jsconfirm(struct_,
|
||||
CefBrowserCppToC::Wrap(browser), CefFrameCppToC::Wrap(frame),
|
||||
message.c_str(), &ret);
|
||||
retval = (ret ? true : false);
|
||||
return rv;
|
||||
}
|
||||
|
||||
CefHandler::RetVal CefHandlerCToCpp::HandleJSPrompt(
|
||||
CefRefPtr<CefBrowser> browser, const std::wstring& message,
|
||||
const std::wstring& defaultValue, bool& retval, std::wstring& result)
|
||||
CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame,
|
||||
const std::wstring& message, const std::wstring& defaultValue, bool& retval,
|
||||
std::wstring& result)
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, handle_jsprompt))
|
||||
return RV_CONTINUE;
|
||||
|
||||
CefBrowserCppToC* browserPtr = new CefBrowserCppToC(browser);
|
||||
browserPtr->AddRef();
|
||||
|
||||
cef_string_t resultRet = NULL;
|
||||
if(!result.empty())
|
||||
resultRet = cef_string_alloc(result.c_str());
|
||||
|
||||
int ret = 0;
|
||||
cef_retval_t rv = struct_->handle_jsprompt(struct_, browserPtr->GetStruct(),
|
||||
cef_retval_t rv = struct_->handle_jsprompt(struct_,
|
||||
CefBrowserCppToC::Wrap(browser), CefFrameCppToC::Wrap(frame),
|
||||
message.c_str(), defaultValue.c_str(), &ret, &resultRet);
|
||||
retval = (ret ? true : false);
|
||||
|
||||
@@ -341,10 +303,8 @@ CefHandler::RetVal CefHandlerCToCpp::HandleBeforeWindowClose(
|
||||
if(CEF_MEMBER_MISSING(struct_, handle_before_window_close))
|
||||
return RV_CONTINUE;
|
||||
|
||||
CefBrowserCppToC* browserPtr = new CefBrowserCppToC(browser);
|
||||
browserPtr->AddRef();
|
||||
|
||||
return struct_->handle_before_window_close(struct_, browserPtr->GetStruct());
|
||||
return struct_->handle_before_window_close(struct_,
|
||||
CefBrowserCppToC::Wrap(browser));
|
||||
}
|
||||
|
||||
CefHandler::RetVal CefHandlerCToCpp::HandleTakeFocus(
|
||||
@@ -353,12 +313,21 @@ CefHandler::RetVal CefHandlerCToCpp::HandleTakeFocus(
|
||||
if(CEF_MEMBER_MISSING(struct_, handle_take_focus))
|
||||
return RV_CONTINUE;
|
||||
|
||||
CefBrowserCppToC* browserPtr = new CefBrowserCppToC(browser);
|
||||
browserPtr->AddRef();
|
||||
return struct_->handle_take_focus(struct_, CefBrowserCppToC::Wrap(browser),
|
||||
reverse);
|
||||
}
|
||||
|
||||
return struct_->handle_take_focus(struct_, browserPtr->GetStruct(), reverse);
|
||||
CefHandler::RetVal CefHandlerCToCpp::HandleJSBinding(
|
||||
CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefV8Value> object)
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, handle_jsbinding))
|
||||
return RV_CONTINUE;
|
||||
|
||||
return struct_->handle_jsbinding(struct_, CefBrowserCppToC::Wrap(browser),
|
||||
CefFrameCppToC::Wrap(frame), CefV8ValueCppToC::Wrap(object));
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
long CefCToCpp<CefHandler, cef_handler_t>::DebugObjCt = 0;
|
||||
long CefCToCpp<CefHandlerCToCpp, CefHandler, cef_handler_t>::DebugObjCt = 0;
|
||||
#endif
|
||||
|
@@ -16,11 +16,12 @@
|
||||
|
||||
// Wrap a C handler structure with a C++ handler class.
|
||||
// This class may be instantiated and accessed DLL-side only.
|
||||
class CefHandlerCToCpp : public CefCToCpp<CefHandler, cef_handler_t>
|
||||
class CefHandlerCToCpp
|
||||
: public CefCToCpp<CefHandlerCToCpp, CefHandler, cef_handler_t>
|
||||
{
|
||||
public:
|
||||
CefHandlerCToCpp(cef_handler_t* str)
|
||||
: CefCToCpp<CefHandler, cef_handler_t>(str) {}
|
||||
: CefCToCpp<CefHandlerCToCpp, CefHandler, cef_handler_t>(str) {}
|
||||
virtual ~CefHandlerCToCpp() {}
|
||||
|
||||
// CefHandler methods
|
||||
@@ -30,15 +31,20 @@ public:
|
||||
std::wstring& url);
|
||||
virtual RetVal HandleAfterCreated(CefRefPtr<CefBrowser> browser);
|
||||
virtual RetVal HandleAddressChange(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
const std::wstring& url);
|
||||
virtual RetVal HandleTitleChange(CefRefPtr<CefBrowser> browser,
|
||||
const std::wstring& title);
|
||||
virtual RetVal HandleBeforeBrowse(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefRequest> request,
|
||||
NavType navType, bool isRedirect);
|
||||
virtual RetVal HandleLoadStart(CefRefPtr<CefBrowser> browser);
|
||||
virtual RetVal HandleLoadEnd(CefRefPtr<CefBrowser> browser);
|
||||
virtual RetVal HandleLoadStart(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame);
|
||||
virtual RetVal HandleLoadEnd(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame);
|
||||
virtual RetVal HandleLoadError(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
ErrorCode errorCode,
|
||||
const std::wstring& failedUrl,
|
||||
std::wstring& errorText);
|
||||
@@ -55,6 +61,7 @@ public:
|
||||
virtual RetVal HandleMenuAction(CefRefPtr<CefBrowser> browser,
|
||||
MenuId menuId);
|
||||
virtual RetVal HandlePrintHeaderFooter(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefPrintInfo& printInfo,
|
||||
const std::wstring& url,
|
||||
const std::wstring& title,
|
||||
@@ -66,10 +73,13 @@ public:
|
||||
std::wstring& bottomCenter,
|
||||
std::wstring& bottomRight);
|
||||
virtual RetVal HandleJSAlert(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
const std::wstring& message);
|
||||
virtual RetVal HandleJSConfirm(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
const std::wstring& message, bool& retval);
|
||||
virtual RetVal HandleJSPrompt(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
const std::wstring& message,
|
||||
const std::wstring& default_value,
|
||||
bool& retval,
|
||||
@@ -77,6 +87,9 @@ public:
|
||||
virtual RetVal HandleBeforeWindowClose(CefRefPtr<CefBrowser> browser);
|
||||
virtual RetVal HandleTakeFocus(CefRefPtr<CefBrowser> browser,
|
||||
bool reverse);
|
||||
virtual RetVal HandleJSBinding(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefV8Value> object);
|
||||
};
|
||||
|
||||
|
||||
|
@@ -1,106 +0,0 @@
|
||||
// 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"
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
long CefCToCpp<CefJSHandler, cef_jshandler_t>::DebugObjCt = 0;
|
||||
#endif
|
@@ -1,45 +0,0 @@
|
||||
// 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.
|
||||
|
||||
#ifndef _JSHANDLER_CTOCPP_H
|
||||
#define _JSHANDLER_CTOCPP_H
|
||||
|
||||
#ifndef BUILDING_CEF_SHARED
|
||||
#pragma message("Warning: "__FILE__" may be accessed DLL-side only")
|
||||
#else // BUILDING_CEF_SHARED
|
||||
|
||||
#include "cef.h"
|
||||
#include "cef_capi.h"
|
||||
#include "ctocpp.h"
|
||||
|
||||
|
||||
// Wrap a C jshandler structure with a C++ jshandler class.
|
||||
// This class may be instantiated and accessed DLL-side only.
|
||||
class CefJSHandlerCToCpp : public CefCToCpp<CefJSHandler, cef_jshandler_t>
|
||||
{
|
||||
public:
|
||||
CefJSHandlerCToCpp(cef_jshandler_t* str)
|
||||
: CefCToCpp<CefJSHandler, cef_jshandler_t>(str) {}
|
||||
virtual ~CefJSHandlerCToCpp() {}
|
||||
|
||||
// CefJSHandler methods
|
||||
virtual bool HasMethod(CefRefPtr<CefBrowser> browser,
|
||||
const std::wstring& name);
|
||||
virtual bool HasProperty(CefRefPtr<CefBrowser> browser,
|
||||
const std::wstring& name);
|
||||
virtual bool SetProperty(CefRefPtr<CefBrowser> browser,
|
||||
const std::wstring& name,
|
||||
const CefRefPtr<CefVariant> value);
|
||||
virtual bool GetProperty(CefRefPtr<CefBrowser> browser,
|
||||
const std::wstring& name,
|
||||
CefRefPtr<CefVariant> value);
|
||||
virtual bool ExecuteMethod(CefRefPtr<CefBrowser> browser,
|
||||
const std::wstring& name,
|
||||
const VariantVector& args,
|
||||
CefRefPtr<CefVariant> retval);
|
||||
};
|
||||
|
||||
|
||||
#endif // BUILDING_CEF_SHARED
|
||||
#endif // _JSHANDLER_CTOCPP_H
|
@@ -28,28 +28,6 @@ void CefRequestCToCpp::SetURL(const std::wstring& url)
|
||||
struct_->set_url(struct_, url.c_str());
|
||||
}
|
||||
|
||||
std::wstring CefRequestCToCpp::GetFrame()
|
||||
{
|
||||
std::wstring str;
|
||||
if(CEF_MEMBER_MISSING(struct_, get_frame))
|
||||
return str;
|
||||
|
||||
cef_string_t cef_str = struct_->get_frame(struct_);
|
||||
if(cef_str) {
|
||||
str = cef_str;
|
||||
cef_string_free(cef_str);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
void CefRequestCToCpp::SetFrame(const std::wstring& frame)
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, set_frame))
|
||||
return;
|
||||
|
||||
struct_->set_frame(struct_, frame.c_str());
|
||||
}
|
||||
|
||||
std::wstring CefRequestCToCpp::GetMethod()
|
||||
{
|
||||
std::wstring str;
|
||||
@@ -78,14 +56,9 @@ CefRefPtr<CefPostData> CefRequestCToCpp::GetPostData()
|
||||
return NULL;
|
||||
|
||||
cef_post_data_t* postDataStruct = struct_->get_post_data(struct_);
|
||||
if(!postDataStruct)
|
||||
return NULL;
|
||||
|
||||
CefPostDataCToCpp* pdp = new CefPostDataCToCpp(postDataStruct);
|
||||
CefRefPtr<CefPostData> postDataPtr(pdp);
|
||||
pdp->UnderlyingRelease();
|
||||
|
||||
return postDataPtr;
|
||||
if(postDataStruct)
|
||||
return CefPostDataCToCpp::Wrap(postDataStruct);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void CefRequestCToCpp::SetPostData(CefRefPtr<CefPostData> postData)
|
||||
@@ -94,11 +67,9 @@ void CefRequestCToCpp::SetPostData(CefRefPtr<CefPostData> postData)
|
||||
return;
|
||||
|
||||
cef_post_data_t* postDataStruct = NULL;
|
||||
if(postData.get()) {
|
||||
CefPostDataCToCpp* pdp = static_cast<CefPostDataCToCpp*>(postData.get());
|
||||
pdp->UnderlyingAddRef();
|
||||
postDataStruct = pdp->GetStruct();
|
||||
}
|
||||
if(postData.get())
|
||||
postDataStruct = CefPostDataCToCpp::Unwrap(postData);
|
||||
|
||||
struct_->set_post_data(struct_, postDataStruct);
|
||||
}
|
||||
|
||||
@@ -136,7 +107,6 @@ void CefRequestCToCpp::SetHeaderMap(const HeaderMap& headerMap)
|
||||
}
|
||||
|
||||
void CefRequestCToCpp::Set(const std::wstring& url,
|
||||
const std::wstring& frame,
|
||||
const std::wstring& method,
|
||||
CefRefPtr<CefPostData> postData,
|
||||
const HeaderMap& headerMap)
|
||||
@@ -145,11 +115,8 @@ void CefRequestCToCpp::Set(const std::wstring& url,
|
||||
return;
|
||||
|
||||
cef_post_data_t* postDataStruct = NULL;
|
||||
if(postData.get()) {
|
||||
CefPostDataCToCpp* pdp = static_cast<CefPostDataCToCpp*>(postData.get());
|
||||
pdp->UnderlyingAddRef();
|
||||
postDataStruct = pdp->GetStruct();
|
||||
}
|
||||
if(postData.get())
|
||||
postDataStruct = CefPostDataCToCpp::Unwrap(postData);
|
||||
|
||||
cef_string_map_t map = NULL;
|
||||
if(!headerMap.empty()) {
|
||||
@@ -159,15 +126,14 @@ void CefRequestCToCpp::Set(const std::wstring& url,
|
||||
transfer_string_map_contents(headerMap, map);
|
||||
}
|
||||
|
||||
struct_->set(struct_, url.c_str(), frame.c_str(), method.c_str(),
|
||||
postDataStruct, map);
|
||||
struct_->set(struct_, url.c_str(), method.c_str(), postDataStruct, map);
|
||||
|
||||
if(map)
|
||||
cef_string_map_free(map);
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
long CefCToCpp<CefRequest, cef_request_t>::DebugObjCt = 0;
|
||||
long CefCToCpp<CefRequestCToCpp, CefRequest, cef_request_t>::DebugObjCt = 0;
|
||||
#endif
|
||||
|
||||
|
||||
@@ -188,16 +154,10 @@ void CefPostDataCToCpp::GetElements(ElementVector& elements)
|
||||
int count = (int)GetElementCount();
|
||||
|
||||
cef_post_data_element_t* structPtr;
|
||||
CefPostDataElementCToCpp* pdep;
|
||||
for(int i = 0; i < count; ++i) {
|
||||
structPtr = struct_->get_element(struct_, i);
|
||||
if(!structPtr)
|
||||
continue;
|
||||
|
||||
pdep = new CefPostDataElementCToCpp(structPtr);
|
||||
CefRefPtr<CefPostDataElement> elementPtr(pdep);
|
||||
pdep->UnderlyingRelease();
|
||||
elements.push_back(elementPtr);
|
||||
if(structPtr)
|
||||
elements.push_back(CefPostDataElementCToCpp::Wrap(structPtr));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -207,10 +167,8 @@ bool CefPostDataCToCpp::RemoveElement(CefRefPtr<CefPostDataElement> element)
|
||||
if(CEF_MEMBER_MISSING(struct_, remove_element) || !element.get())
|
||||
return false;
|
||||
|
||||
CefPostDataElementCToCpp* pdep =
|
||||
static_cast<CefPostDataElementCToCpp*>(element.get());
|
||||
pdep->UnderlyingAddRef();
|
||||
return struct_->remove_element(struct_, pdep->GetStruct());
|
||||
return struct_->remove_element(struct_,
|
||||
CefPostDataElementCToCpp::Unwrap(element));
|
||||
}
|
||||
|
||||
bool CefPostDataCToCpp::AddElement(CefRefPtr<CefPostDataElement> element)
|
||||
@@ -219,10 +177,8 @@ bool CefPostDataCToCpp::AddElement(CefRefPtr<CefPostDataElement> element)
|
||||
if(CEF_MEMBER_MISSING(struct_, add_element) || !element.get())
|
||||
return false;
|
||||
|
||||
CefPostDataElementCToCpp* pdep =
|
||||
static_cast<CefPostDataElementCToCpp*>(element.get());
|
||||
pdep->UnderlyingAddRef();
|
||||
return struct_->add_element(struct_, pdep->GetStruct());
|
||||
return struct_->add_element(struct_,
|
||||
CefPostDataElementCToCpp::Unwrap(element));
|
||||
}
|
||||
|
||||
void CefPostDataCToCpp::RemoveElements()
|
||||
@@ -234,7 +190,7 @@ void CefPostDataCToCpp::RemoveElements()
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
long CefCToCpp<CefPostData, cef_post_data_t>::DebugObjCt = 0;
|
||||
long CefCToCpp<CefPostDataCToCpp, CefPostData, cef_post_data_t>::DebugObjCt = 0;
|
||||
#endif
|
||||
|
||||
|
||||
@@ -302,5 +258,6 @@ size_t CefPostDataElementCToCpp::GetBytes(size_t size, void *bytes)
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
long CefCToCpp<CefPostDataElement, cef_post_data_element_t>::DebugObjCt = 0;
|
||||
long CefCToCpp<CefPostDataElementCToCpp, CefPostDataElement,
|
||||
cef_post_data_element_t>::DebugObjCt = 0;
|
||||
#endif
|
||||
|
@@ -16,18 +16,17 @@
|
||||
|
||||
// Wrap a C request structure with a C++ request class.
|
||||
// This class may be instantiated and accessed wrapper-side only.
|
||||
class CefRequestCToCpp : public CefCToCpp<CefRequest, cef_request_t>
|
||||
class CefRequestCToCpp
|
||||
: public CefCToCpp<CefRequestCToCpp, CefRequest, cef_request_t>
|
||||
{
|
||||
public:
|
||||
CefRequestCToCpp(cef_request_t* str)
|
||||
: CefCToCpp<CefRequest, cef_request_t>(str) {}
|
||||
: CefCToCpp<CefRequestCToCpp, CefRequest, cef_request_t>(str) {}
|
||||
virtual ~CefRequestCToCpp() {}
|
||||
|
||||
// CefRequest methods
|
||||
virtual std::wstring GetURL();
|
||||
virtual void SetURL(const std::wstring& url);
|
||||
virtual std::wstring GetFrame();
|
||||
virtual void SetFrame(const std::wstring& url);
|
||||
virtual std::wstring GetMethod();
|
||||
virtual void SetMethod(const std::wstring& method);
|
||||
virtual CefRefPtr<CefPostData> GetPostData();
|
||||
@@ -35,7 +34,6 @@ public:
|
||||
virtual void GetHeaderMap(HeaderMap& headerMap);
|
||||
virtual void SetHeaderMap(const HeaderMap& headerMap);
|
||||
virtual void Set(const std::wstring& url,
|
||||
const std::wstring& frame,
|
||||
const std::wstring& method,
|
||||
CefRefPtr<CefPostData> postData,
|
||||
const HeaderMap& headerMap);
|
||||
@@ -44,11 +42,12 @@ public:
|
||||
|
||||
// Wrap a C post data structure with a C++ post data class.
|
||||
// This class may be instantiated and accessed wrapper-side only.
|
||||
class CefPostDataCToCpp : public CefCToCpp<CefPostData, cef_post_data_t>
|
||||
class CefPostDataCToCpp
|
||||
: public CefCToCpp<CefPostDataCToCpp, CefPostData, cef_post_data_t>
|
||||
{
|
||||
public:
|
||||
CefPostDataCToCpp(cef_post_data_t* str)
|
||||
: CefCToCpp<CefPostData, cef_post_data_t>(str) {}
|
||||
: CefCToCpp<CefPostDataCToCpp, CefPostData, cef_post_data_t>(str) {}
|
||||
virtual ~CefPostDataCToCpp() {}
|
||||
|
||||
// CefPostData methods
|
||||
@@ -62,12 +61,14 @@ public:
|
||||
|
||||
// Wrap a C post data element structure with a C++ post data element class.
|
||||
// This class may be instantiated and accessed wrapper-side only.
|
||||
class CefPostDataElementCToCpp :
|
||||
public CefCToCpp<CefPostDataElement, cef_post_data_element_t>
|
||||
class CefPostDataElementCToCpp
|
||||
: public CefCToCpp<CefPostDataElementCToCpp, CefPostDataElement,
|
||||
cef_post_data_element_t>
|
||||
{
|
||||
public:
|
||||
CefPostDataElementCToCpp(cef_post_data_element_t* str)
|
||||
: CefCToCpp<CefPostDataElement, cef_post_data_element_t>(str) {}
|
||||
: CefCToCpp<CefPostDataElementCToCpp, CefPostDataElement,
|
||||
cef_post_data_element_t>(str) {}
|
||||
virtual ~CefPostDataElementCToCpp() {}
|
||||
|
||||
// CefPostDataElement methods
|
||||
|
@@ -39,7 +39,8 @@ int CefStreamReaderCToCpp::Eof()
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
long CefCToCpp<CefStreamReader, cef_stream_reader_t>::DebugObjCt = 0;
|
||||
long CefCToCpp<CefStreamReaderCToCpp, CefStreamReader,
|
||||
cef_stream_reader_t>::DebugObjCt = 0;
|
||||
#endif
|
||||
|
||||
|
||||
@@ -76,5 +77,6 @@ int CefStreamWriterCToCpp::Flush()
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
long CefCToCpp<CefStreamWriter, cef_stream_writer_t>::DebugObjCt = 0;
|
||||
long CefCToCpp<CefStreamWriterCToCpp, CefStreamWriter,
|
||||
cef_stream_writer_t>::DebugObjCt = 0;
|
||||
#endif
|
||||
|
@@ -16,12 +16,14 @@
|
||||
|
||||
// Wrap a C stream reader structure with a C++ stream reader class.
|
||||
// This class may be instantiated and accessed wrapper-side only.
|
||||
class CefStreamReaderCToCpp :
|
||||
public CefCToCpp<CefStreamReader, cef_stream_reader_t>
|
||||
class CefStreamReaderCToCpp
|
||||
: public CefCToCpp<CefStreamReaderCToCpp, CefStreamReader,
|
||||
cef_stream_reader_t>
|
||||
{
|
||||
public:
|
||||
CefStreamReaderCToCpp(cef_stream_reader_t* str)
|
||||
: CefCToCpp<CefStreamReader, cef_stream_reader_t>(str) {}
|
||||
: CefCToCpp<CefStreamReaderCToCpp, CefStreamReader,
|
||||
cef_stream_reader_t>(str) {}
|
||||
virtual ~CefStreamReaderCToCpp() {}
|
||||
|
||||
// CefStreamReader methods
|
||||
@@ -34,12 +36,14 @@ public:
|
||||
|
||||
// Wrap a C stream writer structure with a C++ stream writer class.
|
||||
// This class may be instantiated and accessed wrapper-side only.
|
||||
class CefStreamWriterCToCpp :
|
||||
public CefCToCpp<CefStreamWriter, cef_stream_writer_t>
|
||||
class CefStreamWriterCToCpp
|
||||
: public CefCToCpp<CefStreamWriterCToCpp, CefStreamWriter,
|
||||
cef_stream_writer_t>
|
||||
{
|
||||
public:
|
||||
CefStreamWriterCToCpp(cef_stream_writer_t* str)
|
||||
: CefCToCpp<CefStreamWriter, cef_stream_writer_t>(str) {}
|
||||
: CefCToCpp<CefStreamWriterCToCpp, CefStreamWriter,
|
||||
cef_stream_writer_t>(str) {}
|
||||
virtual ~CefStreamWriterCToCpp() {}
|
||||
|
||||
// CefStreamWriter methods
|
||||
|
49
libcef_dll/ctocpp/v8handler_ctocpp.cc
Normal file
49
libcef_dll/ctocpp/v8handler_ctocpp.cc
Normal file
@@ -0,0 +1,49 @@
|
||||
// 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 "ctocpp/v8handler_ctocpp.h"
|
||||
#include "cpptoc/v8value_cpptoc.h"
|
||||
|
||||
|
||||
bool CefV8HandlerCToCpp::Execute(const std::wstring& name,
|
||||
CefRefPtr<CefV8Value> object,
|
||||
CefV8ValueList& arguments,
|
||||
CefRefPtr<CefV8Value>& retval,
|
||||
std::wstring& exception)
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, execute))
|
||||
return RV_CONTINUE;
|
||||
|
||||
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] = CefV8ValueCppToC::Wrap(arguments[i]);
|
||||
}
|
||||
|
||||
cef_v8value_t* retvalStruct = NULL;
|
||||
cef_string_t exceptionStr = NULL;
|
||||
|
||||
int rv = struct_->execute(struct_, name.c_str(),
|
||||
CefV8ValueCppToC::Wrap(object), argsSize, argsStructPtr, &retvalStruct,
|
||||
&exceptionStr);
|
||||
if(retvalStruct)
|
||||
retval = CefV8ValueCppToC::Unwrap(retvalStruct);
|
||||
if(exceptionStr) {
|
||||
exception = exceptionStr;
|
||||
cef_string_free(exceptionStr);
|
||||
}
|
||||
|
||||
if(argsStructPtr)
|
||||
delete [] argsStructPtr;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
long CefCToCpp<CefV8HandlerCToCpp, CefV8Handler, cef_v8handler_t>::DebugObjCt
|
||||
= 0;
|
||||
#endif
|
37
libcef_dll/ctocpp/v8handler_ctocpp.h
Normal file
37
libcef_dll/ctocpp/v8handler_ctocpp.h
Normal file
@@ -0,0 +1,37 @@
|
||||
// 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.
|
||||
|
||||
#ifndef _V8HANDLER_CTOCPP_H
|
||||
#define _V8HANDLER_CTOCPP_H
|
||||
|
||||
#ifndef BUILDING_CEF_SHARED
|
||||
#pragma message("Warning: "__FILE__" may be accessed DLL-side only")
|
||||
#else // BUILDING_CEF_SHARED
|
||||
|
||||
#include "cef.h"
|
||||
#include "cef_capi.h"
|
||||
#include "ctocpp.h"
|
||||
|
||||
|
||||
// Wrap a C v8handler structure with a C++ v8handler class.
|
||||
// This class may be instantiated and accessed DLL-side only.
|
||||
class CefV8HandlerCToCpp
|
||||
: public CefCToCpp<CefV8HandlerCToCpp, CefV8Handler, cef_v8handler_t>
|
||||
{
|
||||
public:
|
||||
CefV8HandlerCToCpp(cef_v8handler_t* str)
|
||||
: CefCToCpp<CefV8HandlerCToCpp, CefV8Handler, cef_v8handler_t>(str) {}
|
||||
virtual ~CefV8HandlerCToCpp() {}
|
||||
|
||||
// CefV8Handler methods
|
||||
virtual bool Execute(const std::wstring& name,
|
||||
CefRefPtr<CefV8Value> object,
|
||||
CefV8ValueList& arguments,
|
||||
CefRefPtr<CefV8Value>& retval,
|
||||
std::wstring& exception);
|
||||
};
|
||||
|
||||
|
||||
#endif // BUILDING_CEF_SHARED
|
||||
#endif // _V8HANDLER_CTOCPP_H
|
293
libcef_dll/ctocpp/v8value_ctocpp.cc
Normal file
293
libcef_dll/ctocpp/v8value_ctocpp.cc
Normal file
@@ -0,0 +1,293 @@
|
||||
// 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"
|
||||
|
||||
|
||||
bool CefV8ValueCToCpp::IsUndefined()
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, is_undefined))
|
||||
return false;
|
||||
|
||||
return struct_->is_undefined(struct_);
|
||||
}
|
||||
|
||||
bool CefV8ValueCToCpp::IsNull()
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, is_null))
|
||||
return false;
|
||||
|
||||
return struct_->is_null(struct_);
|
||||
}
|
||||
|
||||
bool CefV8ValueCToCpp::IsBool()
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, is_bool))
|
||||
return false;
|
||||
|
||||
return struct_->is_bool(struct_);
|
||||
}
|
||||
|
||||
bool CefV8ValueCToCpp::IsInt()
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, is_int))
|
||||
return false;
|
||||
|
||||
return struct_->is_int(struct_);
|
||||
}
|
||||
|
||||
bool CefV8ValueCToCpp::IsDouble()
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, is_double))
|
||||
return false;
|
||||
|
||||
return struct_->is_double(struct_);
|
||||
}
|
||||
|
||||
bool CefV8ValueCToCpp::IsString()
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, is_string))
|
||||
return false;
|
||||
|
||||
return struct_->is_string(struct_);
|
||||
}
|
||||
|
||||
bool CefV8ValueCToCpp::IsObject()
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, is_object))
|
||||
return false;
|
||||
|
||||
return struct_->is_object(struct_);
|
||||
}
|
||||
|
||||
bool CefV8ValueCToCpp::IsArray()
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, is_array))
|
||||
return false;
|
||||
|
||||
return struct_->is_array(struct_);
|
||||
}
|
||||
|
||||
bool CefV8ValueCToCpp::IsFunction()
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, is_function))
|
||||
return false;
|
||||
|
||||
return struct_->is_function(struct_);
|
||||
}
|
||||
|
||||
bool CefV8ValueCToCpp::GetBoolValue()
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, get_bool_value))
|
||||
return false;
|
||||
|
||||
return struct_->get_bool_value(struct_);
|
||||
}
|
||||
|
||||
int CefV8ValueCToCpp::GetIntValue()
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, get_int_value))
|
||||
return 0;
|
||||
|
||||
return struct_->get_int_value(struct_);
|
||||
}
|
||||
|
||||
double CefV8ValueCToCpp::GetDoubleValue()
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, get_double_value))
|
||||
return 0.;
|
||||
|
||||
return struct_->get_double_value(struct_);
|
||||
}
|
||||
|
||||
std::wstring CefV8ValueCToCpp::GetStringValue()
|
||||
{
|
||||
std::wstring str;
|
||||
if(CEF_MEMBER_MISSING(struct_, get_string_value))
|
||||
return str;
|
||||
|
||||
cef_string_t cef_str = struct_->get_string_value(struct_);
|
||||
if(cef_str) {
|
||||
str = cef_str;
|
||||
cef_string_free(cef_str);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
bool CefV8ValueCToCpp::HasValue(const std::wstring& key)
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, has_value_bykey))
|
||||
return false;
|
||||
|
||||
return struct_->has_value_bykey(struct_, key.c_str());
|
||||
}
|
||||
|
||||
bool CefV8ValueCToCpp::HasValue(int index)
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, has_value_byindex))
|
||||
return false;
|
||||
|
||||
return struct_->has_value_byindex(struct_, index);
|
||||
}
|
||||
|
||||
bool CefV8ValueCToCpp::DeleteValue(const std::wstring& key)
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, delete_value_bykey))
|
||||
return false;
|
||||
|
||||
return struct_->delete_value_bykey(struct_, key.c_str());
|
||||
}
|
||||
|
||||
bool CefV8ValueCToCpp::DeleteValue(int index)
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, delete_value_byindex))
|
||||
return false;
|
||||
|
||||
return struct_->delete_value_byindex(struct_, index);
|
||||
}
|
||||
|
||||
CefRefPtr<CefV8Value> CefV8ValueCToCpp::GetValue(const std::wstring& key)
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, get_value_bykey))
|
||||
return false;
|
||||
|
||||
cef_v8value_t* valueStruct = struct_->get_value_bykey(struct_, key.c_str());
|
||||
if(valueStruct)
|
||||
return CefV8ValueCToCpp::Wrap(valueStruct);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CefRefPtr<CefV8Value> CefV8ValueCToCpp::GetValue(int index)
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, get_value_byindex))
|
||||
return false;
|
||||
|
||||
cef_v8value_t* valueStruct = struct_->get_value_byindex(struct_, index);
|
||||
if(valueStruct)
|
||||
return CefV8ValueCToCpp::Wrap(valueStruct);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool CefV8ValueCToCpp::SetValue(const std::wstring& key, CefRefPtr<CefV8Value> value)
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, set_value_bykey))
|
||||
return false;
|
||||
|
||||
return struct_->set_value_bykey(struct_, key.c_str(),
|
||||
CefV8ValueCToCpp::Unwrap(value));
|
||||
}
|
||||
|
||||
bool CefV8ValueCToCpp::SetValue(int index, CefRefPtr<CefV8Value> value)
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, set_value_byindex))
|
||||
return false;
|
||||
|
||||
return struct_->set_value_byindex(struct_, index,
|
||||
CefV8ValueCToCpp::Unwrap(value));
|
||||
}
|
||||
|
||||
bool CefV8ValueCToCpp::GetKeys(std::vector<std::wstring>& keys)
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, get_keys))
|
||||
return false;
|
||||
|
||||
cef_string_list_t list = cef_string_list_alloc();
|
||||
if(struct_->get_keys(struct_, list)) {
|
||||
cef_string_t str;
|
||||
int size = cef_string_list_size(list);
|
||||
for(int i = 0; i < size; ++i) {
|
||||
str = cef_string_list_value(list, i);
|
||||
keys.push_back(str);
|
||||
cef_string_free(str);
|
||||
}
|
||||
cef_string_list_free(list);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
CefRefPtr<CefBase> CefV8ValueCToCpp::GetUserData()
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, get_user_data))
|
||||
return false;
|
||||
|
||||
cef_base_t* baseStruct = struct_->get_user_data(struct_);
|
||||
if(baseStruct)
|
||||
return CefBaseCppToC::Unwrap(baseStruct);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int CefV8ValueCToCpp::GetArrayLength()
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, get_array_length))
|
||||
return 0;
|
||||
|
||||
return struct_->get_array_length(struct_);
|
||||
}
|
||||
|
||||
std::wstring CefV8ValueCToCpp::GetFunctionName()
|
||||
{
|
||||
std::wstring str;
|
||||
if(CEF_MEMBER_MISSING(struct_, get_function_name))
|
||||
return str;
|
||||
|
||||
cef_string_t cef_str = struct_->get_function_name(struct_);
|
||||
if(cef_str) {
|
||||
str = cef_str;
|
||||
cef_string_free(cef_str);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
CefRefPtr<CefV8Handler> CefV8ValueCToCpp::GetFunctionHandler()
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, get_function_handler))
|
||||
return false;
|
||||
|
||||
cef_v8handler_t* handlerStruct = struct_->get_function_handler(struct_);
|
||||
if(handlerStruct)
|
||||
return CefV8HandlerCppToC::Unwrap(handlerStruct);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool CefV8ValueCToCpp::ExecuteFunction(CefRefPtr<CefV8Value> object,
|
||||
CefV8ValueList& arguments,
|
||||
CefRefPtr<CefV8Value>& retval,
|
||||
std::wstring& exception)
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, execute_function))
|
||||
return RV_CONTINUE;
|
||||
|
||||
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;
|
||||
cef_string_t exceptionStr = NULL;
|
||||
|
||||
int rv = struct_->execute_function(struct_, CefV8ValueCToCpp::Unwrap(object),
|
||||
argsSize, argsStructPtr, &retvalStruct, &exceptionStr);
|
||||
if(retvalStruct)
|
||||
retval = CefV8ValueCToCpp::Wrap(retvalStruct);
|
||||
if(exceptionStr) {
|
||||
exception = exceptionStr;
|
||||
cef_string_free(exceptionStr);
|
||||
}
|
||||
|
||||
if(argsStructPtr)
|
||||
delete [] argsStructPtr;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
#ifdef _DEBUG
|
||||
long CefCToCpp<CefV8ValueCToCpp, CefV8Value, cef_v8value_t>::DebugObjCt = 0;
|
||||
#endif
|
62
libcef_dll/ctocpp/v8value_ctocpp.h
Normal file
62
libcef_dll/ctocpp/v8value_ctocpp.h
Normal file
@@ -0,0 +1,62 @@
|
||||
// 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.
|
||||
|
||||
#ifndef _V8VALUE_CTOCPP_H
|
||||
#define _V8VALUE_CTOCPP_H
|
||||
|
||||
#ifndef USING_CEF_SHARED
|
||||
#pragma message("Warning: "__FILE__" may be accessed wrapper-side only")
|
||||
#else // USING_CEF_SHARED
|
||||
|
||||
#include "cef.h"
|
||||
#include "cef_capi.h"
|
||||
#include "ctocpp.h"
|
||||
|
||||
|
||||
// Wrap a C v8value structure with a C++ v8value class.
|
||||
// This class may be instantiated and accessed DLL-side only.
|
||||
class CefV8ValueCToCpp
|
||||
: public CefCToCpp<CefV8ValueCToCpp, CefV8Value, cef_v8value_t>
|
||||
{
|
||||
public:
|
||||
CefV8ValueCToCpp(cef_v8value_t* str)
|
||||
: CefCToCpp<CefV8ValueCToCpp, CefV8Value, cef_v8value_t>(str) {}
|
||||
virtual ~CefV8ValueCToCpp() {}
|
||||
|
||||
// CefV8Value methods
|
||||
virtual bool IsUndefined();
|
||||
virtual bool IsNull();
|
||||
virtual bool IsBool();
|
||||
virtual bool IsInt();
|
||||
virtual bool IsDouble();
|
||||
virtual bool IsString();
|
||||
virtual bool IsObject();
|
||||
virtual bool IsArray();
|
||||
virtual bool IsFunction();
|
||||
virtual bool GetBoolValue();
|
||||
virtual int GetIntValue();
|
||||
virtual double GetDoubleValue();
|
||||
virtual std::wstring GetStringValue();
|
||||
virtual bool HasValue(const std::wstring& key);
|
||||
virtual bool HasValue(int index);
|
||||
virtual bool DeleteValue(const std::wstring& key);
|
||||
virtual bool DeleteValue(int index);
|
||||
virtual CefRefPtr<CefV8Value> GetValue(const std::wstring& key);
|
||||
virtual CefRefPtr<CefV8Value> GetValue(int index);
|
||||
virtual bool SetValue(const std::wstring& key, CefRefPtr<CefV8Value> value);
|
||||
virtual bool SetValue(int index, CefRefPtr<CefV8Value> value);
|
||||
virtual bool GetKeys(std::vector<std::wstring>& keys);
|
||||
virtual CefRefPtr<CefBase> GetUserData();
|
||||
virtual int GetArrayLength();
|
||||
virtual std::wstring GetFunctionName();
|
||||
virtual CefRefPtr<CefV8Handler> GetFunctionHandler();
|
||||
virtual bool ExecuteFunction(CefRefPtr<CefV8Value> object,
|
||||
CefV8ValueList& arguments,
|
||||
CefRefPtr<CefV8Value>& retval,
|
||||
std::wstring& exception);
|
||||
};
|
||||
|
||||
|
||||
#endif // USING_CEF_SHARED
|
||||
#endif // _V8VALUE_CTOCPP_H
|
@@ -1,300 +0,0 @@
|
||||
// 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 "ctocpp/variant_ctocpp.h"
|
||||
|
||||
|
||||
CefVariant::Type CefVariantCToCpp::GetType()
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, get_type))
|
||||
return VARIANT_TYPE_NULL;
|
||||
|
||||
return struct_->get_type(struct_);
|
||||
}
|
||||
|
||||
void CefVariantCToCpp::SetNull()
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, set_null))
|
||||
return;
|
||||
|
||||
return struct_->set_null(struct_);
|
||||
}
|
||||
|
||||
void CefVariantCToCpp::SetBool(bool val)
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, set_bool))
|
||||
return;
|
||||
|
||||
return struct_->set_bool(struct_, val);
|
||||
}
|
||||
|
||||
void CefVariantCToCpp::SetInt(int val)
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, set_int))
|
||||
return;
|
||||
|
||||
return struct_->set_int(struct_, val);
|
||||
}
|
||||
|
||||
void CefVariantCToCpp::SetDouble(double val)
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, set_double))
|
||||
return;
|
||||
|
||||
return struct_->set_double(struct_, val);
|
||||
}
|
||||
|
||||
void CefVariantCToCpp::SetString(const std::wstring& val)
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, set_string))
|
||||
return;
|
||||
|
||||
return struct_->set_string(struct_, val.c_str());
|
||||
}
|
||||
|
||||
void CefVariantCToCpp::SetBoolArray(const std::vector<bool>& val)
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, set_bool_array))
|
||||
return;
|
||||
|
||||
int valSize = (int)val.size();
|
||||
int* valArray = NULL;
|
||||
if(valSize > 0) {
|
||||
valArray = new int[valSize];
|
||||
if(!valArray)
|
||||
return;
|
||||
for(int i = 0; i < valSize; ++i) {
|
||||
valArray[i] = val[i];
|
||||
}
|
||||
}
|
||||
|
||||
struct_->set_bool_array(struct_, valSize, valArray);
|
||||
|
||||
if(valArray)
|
||||
delete [] valArray;
|
||||
}
|
||||
|
||||
void CefVariantCToCpp::SetIntArray(const std::vector<int>& val)
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, set_int_array))
|
||||
return;
|
||||
|
||||
int valSize = (int)val.size();
|
||||
int* valArray = NULL;
|
||||
if(valSize > 0) {
|
||||
valArray = new int[valSize];
|
||||
if(!valArray)
|
||||
return;
|
||||
for(int i = 0; i < valSize; ++i) {
|
||||
valArray[i] = val[i];
|
||||
}
|
||||
}
|
||||
|
||||
struct_->set_int_array(struct_, valSize, valArray);
|
||||
|
||||
if(valArray)
|
||||
delete [] valArray;
|
||||
}
|
||||
|
||||
void CefVariantCToCpp::SetDoubleArray(const std::vector<double>& val)
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, set_double_array))
|
||||
return;
|
||||
|
||||
int valSize = (int)val.size();
|
||||
double* valArray = NULL;
|
||||
if(valSize > 0) {
|
||||
valArray = new double[valSize];
|
||||
if(!valArray)
|
||||
return;
|
||||
for(int i = 0; i < valSize; ++i) {
|
||||
valArray[i] = val[i];
|
||||
}
|
||||
}
|
||||
|
||||
struct_->set_double_array(struct_, valSize, valArray);
|
||||
|
||||
if(valArray)
|
||||
delete [] valArray;
|
||||
}
|
||||
|
||||
void CefVariantCToCpp::SetStringArray(const std::vector<std::wstring>& val)
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, set_string_array))
|
||||
return;
|
||||
|
||||
int valSize = (int)val.size();
|
||||
cef_string_t* valArray = NULL;
|
||||
if(valSize > 0) {
|
||||
valArray = new cef_string_t[valSize];
|
||||
if(!valArray)
|
||||
return;
|
||||
for(int i = 0; i < valSize; ++i) {
|
||||
valArray[i] = cef_string_alloc(val[i].c_str());
|
||||
}
|
||||
}
|
||||
|
||||
struct_->set_string_array(struct_, valSize, valArray);
|
||||
|
||||
if(valArray) {
|
||||
for(int i = 0; i < valSize; ++i) {
|
||||
cef_string_free(valArray[i]);
|
||||
}
|
||||
delete [] valArray;
|
||||
}
|
||||
}
|
||||
|
||||
bool CefVariantCToCpp::GetBool()
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, get_bool))
|
||||
return false;
|
||||
|
||||
return struct_->get_bool(struct_);
|
||||
}
|
||||
|
||||
int CefVariantCToCpp::GetInt()
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, get_int))
|
||||
return 0;
|
||||
|
||||
return struct_->get_int(struct_);
|
||||
}
|
||||
|
||||
double CefVariantCToCpp::GetDouble()
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, get_double))
|
||||
return 0;
|
||||
|
||||
return struct_->get_double(struct_);
|
||||
}
|
||||
|
||||
std::wstring CefVariantCToCpp::GetString()
|
||||
{
|
||||
std::wstring str;
|
||||
if(CEF_MEMBER_MISSING(struct_, get_string))
|
||||
return str;
|
||||
|
||||
cef_string_t cef_str = struct_->get_string(struct_);
|
||||
if(cef_str) {
|
||||
str = cef_str;
|
||||
cef_string_free(cef_str);
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
bool CefVariantCToCpp::GetBoolArray(std::vector<bool>& val)
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, get_bool_array))
|
||||
return false;
|
||||
|
||||
int valSize = GetArraySize();
|
||||
if(valSize < 0)
|
||||
return false;
|
||||
if(valSize == 0)
|
||||
return true;
|
||||
|
||||
int* valArray = new int[valSize];
|
||||
if(!valArray)
|
||||
return false;
|
||||
|
||||
bool rv = struct_->get_bool_array(struct_, valSize, valArray);
|
||||
if(rv) {
|
||||
for(int i = 0; i < valSize; ++i)
|
||||
val.push_back(valArray[i] ? true : false);
|
||||
}
|
||||
delete [] valArray;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
bool CefVariantCToCpp::GetIntArray(std::vector<int>& val)
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, get_int_array))
|
||||
return false;
|
||||
|
||||
int valSize = GetArraySize();
|
||||
if(valSize < 0)
|
||||
return false;
|
||||
if(valSize == 0)
|
||||
return true;
|
||||
|
||||
int* valArray = new int[valSize];
|
||||
if(!valArray)
|
||||
return false;
|
||||
|
||||
bool rv = struct_->get_int_array(struct_, valSize, valArray);
|
||||
if(rv) {
|
||||
for(int i = 0; i < valSize; ++i)
|
||||
val.push_back(valArray[i]);
|
||||
}
|
||||
delete [] valArray;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
bool CefVariantCToCpp::GetDoubleArray(std::vector<double>& val)
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, get_double_array))
|
||||
return false;
|
||||
|
||||
int valSize = GetArraySize();
|
||||
if(valSize < 0)
|
||||
return false;
|
||||
if(valSize == 0)
|
||||
return true;
|
||||
|
||||
double* valArray = new double[valSize];
|
||||
if(!valArray)
|
||||
return false;
|
||||
|
||||
bool rv = struct_->get_double_array(struct_, valSize, valArray);
|
||||
if(rv) {
|
||||
for(int i = 0; i < valSize; ++i)
|
||||
val.push_back(valArray[i]);
|
||||
}
|
||||
delete [] valArray;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
bool CefVariantCToCpp::GetStringArray(std::vector<std::wstring>& val)
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, get_string_array))
|
||||
return false;
|
||||
|
||||
int valSize = GetArraySize();
|
||||
if(valSize < 0)
|
||||
return false;
|
||||
if(valSize == 0)
|
||||
return true;
|
||||
|
||||
cef_string_t* valArray = new cef_string_t[valSize];
|
||||
if(!valArray)
|
||||
return false;
|
||||
|
||||
bool rv = struct_->get_string_array(struct_, valSize, valArray);
|
||||
if(rv) {
|
||||
for(int i = 0; i < valSize; ++i) {
|
||||
val.push_back(valArray[i]);
|
||||
cef_string_free(valArray[i]);
|
||||
}
|
||||
}
|
||||
delete [] valArray;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
int CefVariantCToCpp::GetArraySize()
|
||||
{
|
||||
if(CEF_MEMBER_MISSING(struct_, get_array_size))
|
||||
return -1;
|
||||
|
||||
return struct_->get_array_size(struct_);
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
long CefCToCpp<CefVariant, cef_variant_t>::DebugObjCt = 0;
|
||||
#endif
|
@@ -1,50 +0,0 @@
|
||||
// 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.
|
||||
|
||||
#ifndef _VARIANT_CTOCPP_H
|
||||
#define _VARIANT_CTOCPP_H
|
||||
|
||||
#ifndef USING_CEF_SHARED
|
||||
#pragma message("Warning: "__FILE__" may be accessed wrapper-side only")
|
||||
#else // USING_CEF_SHARED
|
||||
|
||||
#include "cef.h"
|
||||
#include "cef_capi.h"
|
||||
#include "ctocpp.h"
|
||||
|
||||
|
||||
// Wrap a C variant structure with a C++ variant class.
|
||||
// This class may be instantiated and accessed wrapper-side only.
|
||||
class CefVariantCToCpp : public CefCToCpp<CefVariant, cef_variant_t>
|
||||
{
|
||||
public:
|
||||
CefVariantCToCpp(cef_variant_t* str)
|
||||
: CefCToCpp<CefVariant, cef_variant_t>(str) {}
|
||||
virtual ~CefVariantCToCpp() {}
|
||||
|
||||
// CefVariant methods
|
||||
virtual Type GetType();
|
||||
virtual void SetNull();
|
||||
virtual void SetBool(bool val);
|
||||
virtual void SetInt(int val);
|
||||
virtual void SetDouble(double val);
|
||||
virtual void SetString(const std::wstring& val);
|
||||
virtual void SetBoolArray(const std::vector<bool>& val);
|
||||
virtual void SetIntArray(const std::vector<int>& val);
|
||||
virtual void SetDoubleArray(const std::vector<double>& val);
|
||||
virtual void SetStringArray(const std::vector<std::wstring>& val);
|
||||
virtual bool GetBool();
|
||||
virtual int GetInt();
|
||||
virtual double GetDouble();
|
||||
virtual std::wstring GetString();
|
||||
virtual bool GetBoolArray(std::vector<bool>& val);
|
||||
virtual bool GetIntArray(std::vector<int>& val);
|
||||
virtual bool GetDoubleArray(std::vector<double>& val);
|
||||
virtual bool GetStringArray(std::vector<std::wstring>& val);
|
||||
virtual int GetArraySize();
|
||||
};
|
||||
|
||||
|
||||
#endif // USING_CEF_SHARED
|
||||
#endif // _VARIANT_CTOCPP_H
|
@@ -10,10 +10,10 @@
|
||||
#include "cef_nplugin_capi.h"
|
||||
#include "cpptoc/browser_cpptoc.h"
|
||||
#include "cpptoc/request_cpptoc.h"
|
||||
#include "cpptoc/variant_cpptoc.h"
|
||||
#include "cpptoc/stream_cpptoc.h"
|
||||
#include "cpptoc/v8value_cpptoc.h"
|
||||
#include "ctocpp/handler_ctocpp.h"
|
||||
#include "ctocpp/jshandler_ctocpp.h"
|
||||
#include "ctocpp/v8handler_ctocpp.h"
|
||||
#include "base/string_util.h"
|
||||
|
||||
|
||||
@@ -38,9 +38,9 @@ CEF_EXPORT void cef_shutdown()
|
||||
DCHECK(CefPostDataElementCppToC::DebugObjCt == 0);
|
||||
DCHECK(CefStreamReaderCppToC::DebugObjCt == 0);
|
||||
DCHECK(CefStreamWriterCppToC::DebugObjCt == 0);
|
||||
DCHECK(CefVariantCppToC::DebugObjCt == 0);
|
||||
DCHECK(CefV8ValueCppToC::DebugObjCt == 0);
|
||||
DCHECK(CefHandlerCToCpp::DebugObjCt == 0);
|
||||
DCHECK(CefJSHandlerCToCpp::DebugObjCt == 0);
|
||||
DCHECK(CefV8HandlerCToCpp::DebugObjCt == 0);
|
||||
#endif // _DEBUG
|
||||
}
|
||||
|
||||
@@ -49,6 +49,26 @@ CEF_EXPORT void cef_do_message_loop_work()
|
||||
CefDoMessageLoopWork();
|
||||
}
|
||||
|
||||
CEF_EXPORT int cef_register_extension(const wchar_t* extension_name,
|
||||
const wchar_t* javascript_code,
|
||||
struct _cef_v8handler_t* handler)
|
||||
{
|
||||
DCHECK(extension_name);
|
||||
DCHECK(javascript_code);
|
||||
|
||||
CefRefPtr<CefV8Handler> handlerPtr;
|
||||
std::wstring nameStr, codeStr;
|
||||
|
||||
if(handler)
|
||||
handlerPtr = CefV8HandlerCToCpp::Wrap(handler);
|
||||
if(extension_name)
|
||||
nameStr = extension_name;
|
||||
if(javascript_code)
|
||||
codeStr = javascript_code;
|
||||
|
||||
return CefRegisterExtension(nameStr, codeStr, handlerPtr);
|
||||
}
|
||||
|
||||
CEF_EXPORT int cef_create_browser(cef_window_info_t* windowInfo, int popup,
|
||||
cef_handler_t* handler, const wchar_t* url)
|
||||
{
|
||||
@@ -58,11 +78,8 @@ CEF_EXPORT int cef_create_browser(cef_window_info_t* windowInfo, int popup,
|
||||
std::wstring urlStr;
|
||||
CefWindowInfo wi = *windowInfo;
|
||||
|
||||
if(handler) {
|
||||
CefHandlerCToCpp* hp = new CefHandlerCToCpp(handler);
|
||||
handlerPtr = hp;
|
||||
hp->UnderlyingRelease();
|
||||
}
|
||||
if(handler)
|
||||
handlerPtr = CefHandlerCToCpp::Wrap(handler);
|
||||
if(url)
|
||||
urlStr = url;
|
||||
|
||||
@@ -80,54 +97,41 @@ CEF_EXPORT cef_browser_t* cef_create_browser_sync(cef_window_info_t* windowInfo,
|
||||
std::wstring urlStr;
|
||||
CefWindowInfo wi = *windowInfo;
|
||||
|
||||
if(handler) {
|
||||
CefHandlerCToCpp* hp = new CefHandlerCToCpp(handler);
|
||||
handlerPtr = hp;
|
||||
hp->UnderlyingRelease();
|
||||
}
|
||||
if(handler)
|
||||
handlerPtr = CefHandlerCToCpp::Wrap(handler);
|
||||
if(url)
|
||||
urlStr = url;
|
||||
|
||||
cef_browser_t* browserStruct = NULL;
|
||||
CefRefPtr<CefBrowser> browserPtr(
|
||||
CefBrowser::CreateBrowserSync(wi, popup, handlerPtr, urlStr));
|
||||
if(!browserPtr.get())
|
||||
return NULL;
|
||||
|
||||
CefBrowserCppToC* bp = new CefBrowserCppToC(browserPtr);
|
||||
bp->AddRef();
|
||||
return bp->GetStruct();
|
||||
if(browserPtr.get())
|
||||
return CefBrowserCppToC::Wrap(browserPtr);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CEF_EXPORT cef_request_t* cef_create_request()
|
||||
{
|
||||
CefRefPtr<CefRequest> impl = CefRequest::CreateRequest();
|
||||
if(!impl.get())
|
||||
return NULL;
|
||||
CefRequestCppToC* rp = new CefRequestCppToC(impl);
|
||||
rp->AddRef();
|
||||
return rp->GetStruct();
|
||||
if(impl.get())
|
||||
return CefRequestCppToC::Wrap(impl);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CEF_EXPORT cef_post_data_t* cef_create_post_data()
|
||||
{
|
||||
CefRefPtr<CefPostData> impl = CefPostData::CreatePostData();
|
||||
if(!impl.get())
|
||||
return NULL;
|
||||
CefPostDataCppToC* rp = new CefPostDataCppToC(impl);
|
||||
rp->AddRef();
|
||||
return rp->GetStruct();
|
||||
if(impl.get())
|
||||
return CefPostDataCppToC::Wrap(impl);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CEF_EXPORT cef_post_data_element_t* cef_create_post_data_element()
|
||||
{
|
||||
CefRefPtr<CefPostDataElement> impl =
|
||||
CefPostDataElement::CreatePostDataElement();
|
||||
if(!impl.get())
|
||||
return NULL;
|
||||
CefPostDataElementCppToC* rp = new CefPostDataElementCppToC(impl);
|
||||
rp->AddRef();
|
||||
return rp->GetStruct();
|
||||
if(impl.get())
|
||||
return CefPostDataElementCppToC::Wrap(impl);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CEF_EXPORT cef_stream_reader_t* cef_create_stream_reader_for_file(
|
||||
@@ -137,22 +141,106 @@ CEF_EXPORT cef_stream_reader_t* cef_create_stream_reader_for_file(
|
||||
if(fileName)
|
||||
filenamestr = fileName;
|
||||
CefRefPtr<CefStreamReader> impl = CefStreamReader::CreateForFile(filenamestr);
|
||||
if(!impl.get())
|
||||
return NULL;
|
||||
CefStreamReaderCppToC* rp = new CefStreamReaderCppToC(impl);
|
||||
rp->AddRef();
|
||||
return rp->GetStruct();
|
||||
if(impl.get())
|
||||
return CefStreamReaderCppToC::Wrap(impl);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CEF_EXPORT cef_stream_reader_t* cef_create_stream_reader_for_data(void *data,
|
||||
size_t size)
|
||||
{
|
||||
CefRefPtr<CefStreamReader> impl = CefStreamReader::CreateForData(data, size);
|
||||
if(!impl.get())
|
||||
return NULL;
|
||||
CefStreamReaderCppToC* rp = new CefStreamReaderCppToC(impl);
|
||||
rp->AddRef();
|
||||
return rp->GetStruct();
|
||||
if(impl.get())
|
||||
return CefStreamReaderCppToC::Wrap(impl);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CEF_EXPORT cef_v8value_t* cef_create_v8value_undefined()
|
||||
{
|
||||
CefRefPtr<CefV8Value> impl = CefV8Value::CreateUndefined();
|
||||
if(impl.get())
|
||||
return CefV8ValueCppToC::Wrap(impl);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CEF_EXPORT cef_v8value_t* cef_create_v8value_null()
|
||||
{
|
||||
CefRefPtr<CefV8Value> impl = CefV8Value::CreateNull();
|
||||
if(impl.get())
|
||||
return CefV8ValueCppToC::Wrap(impl);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CEF_EXPORT cef_v8value_t* cef_create_v8value_bool(int value)
|
||||
{
|
||||
CefRefPtr<CefV8Value> impl = CefV8Value::CreateBool(value?true:false);
|
||||
if(impl.get())
|
||||
return CefV8ValueCppToC::Wrap(impl);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CEF_EXPORT cef_v8value_t* cef_create_v8value_int(int value)
|
||||
{
|
||||
CefRefPtr<CefV8Value> impl = CefV8Value::CreateInt(value);
|
||||
if(impl.get())
|
||||
return CefV8ValueCppToC::Wrap(impl);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CEF_EXPORT cef_v8value_t* cef_create_v8value_double(double value)
|
||||
{
|
||||
CefRefPtr<CefV8Value> impl = CefV8Value::CreateDouble(value);
|
||||
if(impl.get())
|
||||
return CefV8ValueCppToC::Wrap(impl);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CEF_EXPORT cef_v8value_t* cef_create_v8value_string(const wchar_t* value)
|
||||
{
|
||||
std::wstring valueStr;
|
||||
if(value)
|
||||
valueStr = value;
|
||||
|
||||
CefRefPtr<CefV8Value> impl = CefV8Value::CreateString(valueStr);
|
||||
if(impl.get())
|
||||
return CefV8ValueCppToC::Wrap(impl);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CEF_EXPORT cef_v8value_t* cef_create_v8value_object(cef_base_t* user_data)
|
||||
{
|
||||
CefRefPtr<CefBase> basePtr;
|
||||
if(user_data)
|
||||
basePtr = CefBaseCToCpp::Wrap(user_data);
|
||||
|
||||
CefRefPtr<CefV8Value> impl = CefV8Value::CreateObject(basePtr);
|
||||
if(impl.get())
|
||||
return CefV8ValueCppToC::Wrap(impl);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CEF_EXPORT cef_v8value_t* cef_create_v8value_array()
|
||||
{
|
||||
CefRefPtr<CefV8Value> impl = CefV8Value::CreateArray();
|
||||
if(impl.get())
|
||||
return CefV8ValueCppToC::Wrap(impl);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CEF_EXPORT cef_v8value_t* cef_create_v8value_function(const wchar_t* name,
|
||||
cef_v8handler_t* handler)
|
||||
{
|
||||
std::wstring nameStr;
|
||||
if(name)
|
||||
nameStr = name;
|
||||
CefRefPtr<CefV8Handler> handlerPtr;
|
||||
if(handler)
|
||||
handlerPtr = CefV8HandlerCToCpp::Wrap(handler);
|
||||
|
||||
CefRefPtr<CefV8Value> impl = CefV8Value::CreateFunction(nameStr, handlerPtr);
|
||||
if(impl.get())
|
||||
return CefV8ValueCppToC::Wrap(impl);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CEF_EXPORT int cef_register_plugin(const cef_plugin_info_t* plugin_info)
|
||||
|
@@ -178,6 +178,10 @@
|
||||
RelativePath="..\include\cef_string.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\include\cef_string_list.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\include\cef_string_map.h"
|
||||
>
|
||||
@@ -226,6 +230,30 @@
|
||||
RelativePath=".\cpptoc\cpptoc.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\cpptoc\frame_cpptoc.cc"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
PrecompiledHeaderThrough="../precompiled_libcef.h"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
PrecompiledHeaderThrough="../precompiled_libcef.h"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\cpptoc\frame_cpptoc.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\cpptoc\request_cpptoc.cc"
|
||||
>
|
||||
@@ -275,7 +303,7 @@
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\cpptoc\variant_cpptoc.cc"
|
||||
RelativePath=".\cpptoc\v8value_cpptoc.cc"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
@@ -295,7 +323,7 @@
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\cpptoc\variant_cpptoc.h"
|
||||
RelativePath=".\cpptoc\v8value_cpptoc.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
@@ -331,7 +359,7 @@
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\ctocpp\jshandler_ctocpp.cc"
|
||||
RelativePath=".\ctocpp\v8handler_ctocpp.cc"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
@@ -351,7 +379,7 @@
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\ctocpp\jshandler_ctocpp.h"
|
||||
RelativePath=".\ctocpp\v8handler_ctocpp.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
@@ -375,30 +403,6 @@
|
||||
RelativePath=".\cef_logging.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\cef_string.c"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
UsePrecompiledHeader="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
UsePrecompiledHeader="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\cef_string_map.cc"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libcef_dll.cc"
|
||||
>
|
||||
|
@@ -8,11 +8,11 @@
|
||||
#include "cef_nplugin.h"
|
||||
#include "cef_nplugin_capi.h"
|
||||
#include "../cpptoc/handler_cpptoc.h"
|
||||
#include "../cpptoc/jshandler_cpptoc.h"
|
||||
#include "../cpptoc/v8handler_cpptoc.h"
|
||||
#include "../ctocpp/browser_ctocpp.h"
|
||||
#include "../ctocpp/request_ctocpp.h"
|
||||
#include "../ctocpp/variant_ctocpp.h"
|
||||
#include "../ctocpp/stream_ctocpp.h"
|
||||
#include "../ctocpp/v8value_ctocpp.h"
|
||||
|
||||
|
||||
bool CefInitialize(bool multi_threaded_message_loop,
|
||||
@@ -28,14 +28,14 @@ void CefShutdown()
|
||||
#ifdef _DEBUG
|
||||
// Check that all wrapper objects have been destroyed
|
||||
DCHECK(CefHandlerCppToC::DebugObjCt == 0);
|
||||
DCHECK(CefJSHandlerCppToC::DebugObjCt == 0);
|
||||
DCHECK(CefV8HandlerCppToC::DebugObjCt == 0);
|
||||
DCHECK(CefBrowserCToCpp::DebugObjCt == 0);
|
||||
DCHECK(CefRequestCToCpp::DebugObjCt == 0);
|
||||
DCHECK(CefPostDataCToCpp::DebugObjCt == 0);
|
||||
DCHECK(CefPostDataElementCToCpp::DebugObjCt == 0);
|
||||
DCHECK(CefStreamReaderCToCpp::DebugObjCt == 0);
|
||||
DCHECK(CefStreamWriterCToCpp::DebugObjCt == 0);
|
||||
DCHECK(CefVariantCToCpp::DebugObjCt == 0);
|
||||
DCHECK(CefV8ValueCToCpp::DebugObjCt == 0);
|
||||
#endif // _DEBUG
|
||||
}
|
||||
|
||||
@@ -44,13 +44,20 @@ void CefDoMessageLoopWork()
|
||||
cef_do_message_loop_work();
|
||||
}
|
||||
|
||||
bool CefRegisterExtension(const std::wstring& extension_name,
|
||||
const std::wstring& javascript_code,
|
||||
CefRefPtr<CefV8Handler> handler)
|
||||
{
|
||||
return cef_register_extension(extension_name.c_str(), javascript_code.c_str(),
|
||||
CefV8HandlerCppToC::Wrap(handler));
|
||||
}
|
||||
|
||||
bool CefBrowser::CreateBrowser(CefWindowInfo& windowInfo, bool popup,
|
||||
CefRefPtr<CefHandler> handler,
|
||||
const std::wstring& url)
|
||||
{
|
||||
CefHandlerCppToC* hp = new CefHandlerCppToC(handler);
|
||||
hp->AddRef();
|
||||
return cef_create_browser(&windowInfo, popup, hp->GetStruct(), url.c_str());
|
||||
return cef_create_browser(&windowInfo, popup, CefHandlerCppToC::Wrap(handler),
|
||||
url.c_str());
|
||||
}
|
||||
|
||||
CefRefPtr<CefBrowser> CefBrowser::CreateBrowserSync(CefWindowInfo& windowInfo,
|
||||
@@ -58,75 +65,134 @@ CefRefPtr<CefBrowser> CefBrowser::CreateBrowserSync(CefWindowInfo& windowInfo,
|
||||
CefRefPtr<CefHandler> handler,
|
||||
const std::wstring& url)
|
||||
{
|
||||
CefHandlerCppToC* hp = new CefHandlerCppToC(handler);
|
||||
hp->AddRef();
|
||||
|
||||
cef_browser_t* browserStruct = cef_create_browser_sync(&windowInfo, popup,
|
||||
hp->GetStruct(), url.c_str());
|
||||
if(!browserStruct)
|
||||
return NULL;
|
||||
|
||||
CefBrowserCToCpp* bp = new CefBrowserCToCpp(browserStruct);
|
||||
CefRefPtr<CefBrowser> browserPtr(bp);
|
||||
bp->UnderlyingRelease();
|
||||
|
||||
return browserPtr;
|
||||
cef_browser_t* impl = cef_create_browser_sync(&windowInfo, popup,
|
||||
CefHandlerCppToC::Wrap(handler), url.c_str());
|
||||
if(impl)
|
||||
return CefBrowserCToCpp::Wrap(impl);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CefRefPtr<CefRequest> CreateRequest()
|
||||
{
|
||||
cef_request_t* impl = cef_create_request();
|
||||
if(!impl)
|
||||
return NULL;
|
||||
CefRequestCToCpp* ptr = new CefRequestCToCpp(impl);
|
||||
CefRefPtr<CefRequest> rp(ptr);
|
||||
ptr->UnderlyingRelease();
|
||||
return rp;
|
||||
if(impl)
|
||||
return CefRequestCToCpp::Wrap(impl);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CefRefPtr<CefPostData> CreatePostData()
|
||||
{
|
||||
cef_post_data_t* impl = cef_create_post_data();
|
||||
if(!impl)
|
||||
return NULL;
|
||||
CefPostDataCToCpp* ptr = new CefPostDataCToCpp(impl);
|
||||
CefRefPtr<CefPostData> rp(ptr);
|
||||
ptr->UnderlyingRelease();
|
||||
return rp;
|
||||
if(impl)
|
||||
return CefPostDataCToCpp::Wrap(impl);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CefRefPtr<CefPostDataElement> CreatePostDataElement()
|
||||
{
|
||||
cef_post_data_element_t* impl = cef_create_post_data_element();
|
||||
if(!impl)
|
||||
return NULL;
|
||||
CefPostDataElementCToCpp* ptr = new CefPostDataElementCToCpp(impl);
|
||||
CefRefPtr<CefPostDataElement> rp(ptr);
|
||||
ptr->UnderlyingRelease();
|
||||
return rp;
|
||||
if(impl)
|
||||
return CefPostDataElementCToCpp::Wrap(impl);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CefRefPtr<CefStreamReader> CefStreamReader::CreateForFile(const std::wstring& fileName)
|
||||
{
|
||||
cef_stream_reader_t* impl =
|
||||
cef_create_stream_reader_for_file(fileName.c_str());
|
||||
if(!impl)
|
||||
return NULL;
|
||||
CefStreamReaderCToCpp* ptr = new CefStreamReaderCToCpp(impl);
|
||||
CefRefPtr<CefStreamReader> rp(ptr);
|
||||
ptr->UnderlyingRelease();
|
||||
return rp;
|
||||
if(impl)
|
||||
return CefStreamReaderCToCpp::Wrap(impl);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CefRefPtr<CefStreamReader> CefStreamReader::CreateForData(void *data, size_t size)
|
||||
{
|
||||
cef_stream_reader_t* impl = cef_create_stream_reader_for_data(data, size);
|
||||
if(!impl)
|
||||
return NULL;
|
||||
CefStreamReaderCToCpp* ptr = new CefStreamReaderCToCpp(impl);
|
||||
CefRefPtr<CefStreamReader> rp(ptr);
|
||||
ptr->UnderlyingRelease();
|
||||
return rp;
|
||||
if(impl)
|
||||
return CefStreamReaderCToCpp::Wrap(impl);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CefRefPtr<CefV8Value> CefV8Value::CreateUndefined()
|
||||
{
|
||||
cef_v8value_t* impl = cef_create_v8value_undefined();
|
||||
if(impl)
|
||||
return CefV8ValueCToCpp::Wrap(impl);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CefRefPtr<CefV8Value> CefV8Value::CreateNull()
|
||||
{
|
||||
cef_v8value_t* impl = cef_create_v8value_null();
|
||||
if(impl)
|
||||
return CefV8ValueCToCpp::Wrap(impl);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CefRefPtr<CefV8Value> CefV8Value::CreateBool(bool value)
|
||||
{
|
||||
cef_v8value_t* impl = cef_create_v8value_bool(value);
|
||||
if(impl)
|
||||
return CefV8ValueCToCpp::Wrap(impl);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CefRefPtr<CefV8Value> CefV8Value::CreateInt(int value)
|
||||
{
|
||||
cef_v8value_t* impl = cef_create_v8value_int(value);
|
||||
if(impl)
|
||||
return CefV8ValueCToCpp::Wrap(impl);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CefRefPtr<CefV8Value> CefV8Value::CreateDouble(double value)
|
||||
{
|
||||
cef_v8value_t* impl = cef_create_v8value_double(value);
|
||||
if(impl)
|
||||
return CefV8ValueCToCpp::Wrap(impl);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CefRefPtr<CefV8Value> CefV8Value::CreateString(const std::wstring& value)
|
||||
{
|
||||
cef_v8value_t* impl = cef_create_v8value_string(value.c_str());
|
||||
if(impl)
|
||||
return CefV8ValueCToCpp::Wrap(impl);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CefRefPtr<CefV8Value> CefV8Value::CreateObject(CefRefPtr<CefBase> user_data)
|
||||
{
|
||||
cef_base_t* baseStruct = NULL;
|
||||
if(user_data)
|
||||
baseStruct = CefBaseCppToC::Wrap(user_data);
|
||||
|
||||
cef_v8value_t* impl = cef_create_v8value_object(baseStruct);
|
||||
if(impl)
|
||||
return CefV8ValueCToCpp::Wrap(impl);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CefRefPtr<CefV8Value> CefV8Value::CreateArray()
|
||||
{
|
||||
cef_v8value_t* impl = cef_create_v8value_array();
|
||||
if(impl)
|
||||
return CefV8ValueCToCpp::Wrap(impl);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CefRefPtr<CefV8Value> CefV8Value::CreateFunction(const std::wstring& name,
|
||||
CefRefPtr<CefV8Handler> handler)
|
||||
{
|
||||
cef_v8handler_t* handlerStruct = NULL;
|
||||
if(handler.get())
|
||||
handlerStruct = CefV8HandlerCppToC::Wrap(handler);
|
||||
|
||||
cef_v8value_t* impl = cef_create_v8value_function(name.c_str(),
|
||||
handlerStruct);
|
||||
if(impl)
|
||||
return CefV8ValueCToCpp::Wrap(impl);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool CefRegisterPlugin(const struct CefPluginInfo& plugin_info)
|
||||
|
@@ -142,11 +142,11 @@
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\cpptoc\jshandler_cpptoc.cc"
|
||||
RelativePath="..\cpptoc\v8handler_cpptoc.cc"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\cpptoc\jshandler_cpptoc.h"
|
||||
RelativePath="..\cpptoc\v8handler_cpptoc.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
@@ -165,6 +165,14 @@
|
||||
RelativePath="..\ctocpp\ctocpp.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\ctocpp\frame_ctocpp.cc"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\ctocpp\frame_ctocpp.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\ctocpp\request_ctocpp.cc"
|
||||
>
|
||||
@@ -182,11 +190,11 @@
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\ctocpp\variant_ctocpp.cc"
|
||||
RelativePath="..\ctocpp\v8value_ctocpp.cc"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\ctocpp\variant_ctocpp.h"
|
||||
RelativePath="..\ctocpp\v8value_ctocpp.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
|
Reference in New Issue
Block a user