mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
- Add CefDragHandler to support examination of drag data and cancellation of drag requests (issue #297).
- Mac: Fix dragging of URLs by providing a default image if no drag image is supplied. git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@279 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
@ -12,6 +12,7 @@
|
||||
|
||||
#include "libcef_dll/cpptoc/client_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/display_handler_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/drag_handler_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/find_handler_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/focus_handler_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/jsbinding_handler_cpptoc.h"
|
||||
@ -207,6 +208,21 @@ cef_render_handler_t* CEF_CALLBACK client_get_render_handler(
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cef_drag_handler_t* CEF_CALLBACK client_get_drag_handler(
|
||||
struct _cef_client_t* self)
|
||||
{
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return NULL;
|
||||
|
||||
CefRefPtr<CefDragHandler> handlerPtr =
|
||||
CefClientCppToC::Get(self)->GetDragHandler();
|
||||
if(handlerPtr.get())
|
||||
return CefDragHandlerCppToC::Wrap(handlerPtr);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
// CONSTRUCTOR - Do not edit by hand.
|
||||
|
||||
@ -225,6 +241,7 @@ CefClientCppToC::CefClientCppToC(CefClient* cls)
|
||||
struct_.struct_.get_jsdialog_handler = client_get_jsdialog_handler;
|
||||
struct_.struct_.get_jsbinding_handler = client_get_jsbinding_handler;
|
||||
struct_.struct_.get_render_handler = client_get_render_handler;
|
||||
struct_.struct_.get_drag_handler = client_get_drag_handler;
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
|
174
libcef_dll/cpptoc/drag_data_cpptoc.cc
Normal file
174
libcef_dll/cpptoc/drag_data_cpptoc.cc
Normal file
@ -0,0 +1,174 @@
|
||||
// Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// A portion of this file was generated by the CEF translator tool. When
|
||||
// making changes by hand only do so within the body of existing function
|
||||
// implementations. See the translator.README.txt file in the tools directory
|
||||
// for more information.
|
||||
//
|
||||
|
||||
#include "libcef_dll/cpptoc/drag_data_cpptoc.h"
|
||||
#include "libcef_dll/transfer_util.h"
|
||||
|
||||
|
||||
// MEMBER FUNCTIONS - Body may be edited by hand.
|
||||
|
||||
int CEF_CALLBACK drag_data_is_link(struct _cef_drag_data_t* self)
|
||||
{
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return 0;
|
||||
|
||||
return CefDragDataCppToC::Get(self)->IsLink();
|
||||
}
|
||||
|
||||
int CEF_CALLBACK drag_data_is_fragment(struct _cef_drag_data_t* self)
|
||||
{
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return 0;
|
||||
|
||||
return CefDragDataCppToC::Get(self)->IsFragment();
|
||||
}
|
||||
|
||||
int CEF_CALLBACK drag_data_is_file(struct _cef_drag_data_t* self)
|
||||
{
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return 0;
|
||||
|
||||
return CefDragDataCppToC::Get(self)->IsFile();
|
||||
}
|
||||
|
||||
cef_string_userfree_t CEF_CALLBACK drag_data_get_link_url(
|
||||
struct _cef_drag_data_t* self)
|
||||
{
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return NULL;
|
||||
|
||||
CefString str = CefDragDataCppToC::Get(self)->GetLinkURL();
|
||||
return str.DetachToUserFree();
|
||||
}
|
||||
|
||||
cef_string_userfree_t CEF_CALLBACK drag_data_get_link_title(
|
||||
struct _cef_drag_data_t* self)
|
||||
{
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return NULL;
|
||||
|
||||
CefString str = CefDragDataCppToC::Get(self)->GetLinkTitle();
|
||||
return str.DetachToUserFree();
|
||||
}
|
||||
|
||||
cef_string_userfree_t CEF_CALLBACK drag_data_get_link_metadata(
|
||||
struct _cef_drag_data_t* self)
|
||||
{
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return NULL;
|
||||
|
||||
CefString str = CefDragDataCppToC::Get(self)->GetLinkMetadata();
|
||||
return str.DetachToUserFree();
|
||||
}
|
||||
|
||||
cef_string_userfree_t CEF_CALLBACK drag_data_get_fragment_text(
|
||||
struct _cef_drag_data_t* self)
|
||||
{
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return NULL;
|
||||
|
||||
CefString str = CefDragDataCppToC::Get(self)->GetFragmentText();
|
||||
return str.DetachToUserFree();
|
||||
}
|
||||
|
||||
cef_string_userfree_t CEF_CALLBACK drag_data_get_fragment_html(
|
||||
struct _cef_drag_data_t* self)
|
||||
{
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return NULL;
|
||||
|
||||
CefString str = CefDragDataCppToC::Get(self)->GetFragmentHtml();
|
||||
return str.DetachToUserFree();
|
||||
}
|
||||
|
||||
cef_string_userfree_t CEF_CALLBACK drag_data_get_fragment_base_url(
|
||||
struct _cef_drag_data_t* self)
|
||||
{
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return NULL;
|
||||
|
||||
CefString str = CefDragDataCppToC::Get(self)->GetFragmentBaseURL();
|
||||
return str.DetachToUserFree();
|
||||
}
|
||||
|
||||
cef_string_userfree_t CEF_CALLBACK drag_data_get_file_extension(
|
||||
struct _cef_drag_data_t* self)
|
||||
{
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return NULL;
|
||||
|
||||
CefString str = CefDragDataCppToC::Get(self)->GetFileExtension();
|
||||
return str.DetachToUserFree();
|
||||
}
|
||||
|
||||
cef_string_userfree_t CEF_CALLBACK drag_data_get_file_name(
|
||||
struct _cef_drag_data_t* self)
|
||||
{
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return NULL;
|
||||
|
||||
CefString str = CefDragDataCppToC::Get(self)->GetFileName();
|
||||
return str.DetachToUserFree();
|
||||
}
|
||||
|
||||
int CEF_CALLBACK drag_data_get_file_names(struct _cef_drag_data_t* self,
|
||||
cef_string_list_t names)
|
||||
{
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return 0;
|
||||
|
||||
StringList file_names;
|
||||
if (CefDragDataCppToC::Get(self)->GetFileNames(file_names)) {
|
||||
transfer_string_list_contents(file_names, names);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// CONSTRUCTOR - Do not edit by hand.
|
||||
|
||||
CefDragDataCppToC::CefDragDataCppToC(CefDragData* cls)
|
||||
: CefCppToC<CefDragDataCppToC, CefDragData, cef_drag_data_t>(cls)
|
||||
{
|
||||
struct_.struct_.is_link = drag_data_is_link;
|
||||
struct_.struct_.is_fragment = drag_data_is_fragment;
|
||||
struct_.struct_.is_file = drag_data_is_file;
|
||||
struct_.struct_.get_link_url = drag_data_get_link_url;
|
||||
struct_.struct_.get_link_title = drag_data_get_link_title;
|
||||
struct_.struct_.get_link_metadata = drag_data_get_link_metadata;
|
||||
struct_.struct_.get_fragment_text = drag_data_get_fragment_text;
|
||||
struct_.struct_.get_fragment_html = drag_data_get_fragment_html;
|
||||
struct_.struct_.get_fragment_base_url = drag_data_get_fragment_base_url;
|
||||
struct_.struct_.get_file_extension = drag_data_get_file_extension;
|
||||
struct_.struct_.get_file_name = drag_data_get_file_name;
|
||||
struct_.struct_.get_file_names = drag_data_get_file_names;
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
template<> long CefCppToC<CefDragDataCppToC, CefDragData,
|
||||
cef_drag_data_t>::DebugObjCt = 0;
|
||||
#endif
|
||||
|
34
libcef_dll/cpptoc/drag_data_cpptoc.h
Normal file
34
libcef_dll/cpptoc/drag_data_cpptoc.h
Normal file
@ -0,0 +1,34 @@
|
||||
// Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool and should not edited
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
#ifndef _DRAGDATA_CPPTOC_H
|
||||
#define _DRAGDATA_CPPTOC_H
|
||||
|
||||
#ifndef BUILDING_CEF_SHARED
|
||||
#pragma message("Warning: "__FILE__" may be accessed DLL-side only")
|
||||
#else // BUILDING_CEF_SHARED
|
||||
|
||||
#include "include/cef.h"
|
||||
#include "include/cef_capi.h"
|
||||
#include "libcef_dll/cpptoc/cpptoc.h"
|
||||
|
||||
// Wrap a C++ class with a C structure.
|
||||
// This class may be instantiated and accessed DLL-side only.
|
||||
class CefDragDataCppToC
|
||||
: public CefCppToC<CefDragDataCppToC, CefDragData, cef_drag_data_t>
|
||||
{
|
||||
public:
|
||||
CefDragDataCppToC(CefDragData* cls);
|
||||
virtual ~CefDragDataCppToC() {}
|
||||
};
|
||||
|
||||
#endif // BUILDING_CEF_SHARED
|
||||
#endif // _DRAGDATA_CPPTOC_H
|
||||
|
62
libcef_dll/cpptoc/drag_handler_cpptoc.cc
Normal file
62
libcef_dll/cpptoc/drag_handler_cpptoc.cc
Normal file
@ -0,0 +1,62 @@
|
||||
// Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// A portion of this file was generated by the CEF translator tool. When
|
||||
// making changes by hand only do so within the body of existing function
|
||||
// implementations. See the translator.README.txt file in the tools directory
|
||||
// for more information.
|
||||
//
|
||||
|
||||
#include "libcef_dll/cpptoc/drag_handler_cpptoc.h"
|
||||
#include "libcef_dll/ctocpp/browser_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/drag_data_ctocpp.h"
|
||||
|
||||
|
||||
// MEMBER FUNCTIONS - Body may be edited by hand.
|
||||
|
||||
int CEF_CALLBACK drag_handler_on_drag_start(struct _cef_drag_handler_t* self,
|
||||
cef_browser_t* browser, struct _cef_drag_data_t* dragData,
|
||||
enum cef_drag_operations_mask_t mask)
|
||||
{
|
||||
DCHECK(self);
|
||||
DCHECK(browser);
|
||||
DCHECK(dragData);
|
||||
if (!self || !browser || !dragData)
|
||||
return 0;
|
||||
|
||||
return CefDragHandlerCppToC::Get(self)->OnDragStart(
|
||||
CefBrowserCToCpp::Wrap(browser), CefDragDataCToCpp::Wrap(dragData), mask);
|
||||
}
|
||||
|
||||
int CEF_CALLBACK drag_handler_on_drag_enter(struct _cef_drag_handler_t* self,
|
||||
cef_browser_t* browser, struct _cef_drag_data_t* dragData,
|
||||
enum cef_drag_operations_mask_t mask)
|
||||
{
|
||||
DCHECK(self);
|
||||
DCHECK(browser);
|
||||
DCHECK(dragData);
|
||||
if (!self || !browser || !dragData)
|
||||
return 0;
|
||||
|
||||
return CefDragHandlerCppToC::Get(self)->OnDragEnter(
|
||||
CefBrowserCToCpp::Wrap(browser), CefDragDataCToCpp::Wrap(dragData), mask);
|
||||
}
|
||||
|
||||
|
||||
// CONSTRUCTOR - Do not edit by hand.
|
||||
|
||||
CefDragHandlerCppToC::CefDragHandlerCppToC(CefDragHandler* cls)
|
||||
: CefCppToC<CefDragHandlerCppToC, CefDragHandler, cef_drag_handler_t>(cls)
|
||||
{
|
||||
struct_.struct_.on_drag_start = drag_handler_on_drag_start;
|
||||
struct_.struct_.on_drag_enter = drag_handler_on_drag_enter;
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
template<> long CefCppToC<CefDragHandlerCppToC, CefDragHandler,
|
||||
cef_drag_handler_t>::DebugObjCt = 0;
|
||||
#endif
|
||||
|
34
libcef_dll/cpptoc/drag_handler_cpptoc.h
Normal file
34
libcef_dll/cpptoc/drag_handler_cpptoc.h
Normal file
@ -0,0 +1,34 @@
|
||||
// Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool and should not edited
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
#ifndef _DRAGHANDLER_CPPTOC_H
|
||||
#define _DRAGHANDLER_CPPTOC_H
|
||||
|
||||
#ifndef USING_CEF_SHARED
|
||||
#pragma message("Warning: "__FILE__" may be accessed wrapper-side only")
|
||||
#else // USING_CEF_SHARED
|
||||
|
||||
#include "include/cef.h"
|
||||
#include "include/cef_capi.h"
|
||||
#include "libcef_dll/cpptoc/cpptoc.h"
|
||||
|
||||
// Wrap a C++ class with a C structure.
|
||||
// This class may be instantiated and accessed wrapper-side only.
|
||||
class CefDragHandlerCppToC
|
||||
: public CefCppToC<CefDragHandlerCppToC, CefDragHandler, cef_drag_handler_t>
|
||||
{
|
||||
public:
|
||||
CefDragHandlerCppToC(CefDragHandler* cls);
|
||||
virtual ~CefDragHandlerCppToC() {}
|
||||
};
|
||||
|
||||
#endif // USING_CEF_SHARED
|
||||
#endif // _DRAGHANDLER_CPPTOC_H
|
||||
|
Reference in New Issue
Block a user