- 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:
Marshall Greenblatt
2011-08-22 01:31:55 +00:00
parent 88a46e0b44
commit 1b1255c92d
26 changed files with 1192 additions and 30 deletions

View File

@@ -12,6 +12,7 @@
#include "libcef_dll/ctocpp/client_ctocpp.h"
#include "libcef_dll/ctocpp/display_handler_ctocpp.h"
#include "libcef_dll/ctocpp/drag_handler_ctocpp.h"
#include "libcef_dll/ctocpp/find_handler_ctocpp.h"
#include "libcef_dll/ctocpp/focus_handler_ctocpp.h"
#include "libcef_dll/ctocpp/jsbinding_handler_ctocpp.h"
@@ -175,6 +176,18 @@ CefRefPtr<CefRenderHandler> CefClientCToCpp::GetRenderHandler()
return NULL;
}
CefRefPtr<CefDragHandler> CefClientCToCpp::GetDragHandler()
{
if (CEF_MEMBER_MISSING(struct_, get_drag_handler))
return NULL;
cef_drag_handler_t* handlerStruct = struct_->get_drag_handler(struct_);
if(handlerStruct)
return CefDragHandlerCToCpp::Wrap(handlerStruct);
return NULL;
}
#ifndef NDEBUG
template<> long CefCToCpp<CefClientCToCpp, CefClient,

View File

@@ -43,6 +43,7 @@ public:
virtual CefRefPtr<CefJSDialogHandler> GetJSDialogHandler() OVERRIDE;
virtual CefRefPtr<CefJSBindingHandler> GetJSBindingHandler() OVERRIDE;
virtual CefRefPtr<CefRenderHandler> GetRenderHandler() OVERRIDE;
virtual CefRefPtr<CefDragHandler> GetDragHandler() OVERRIDE;
};
#endif // BUILDING_CEF_SHARED

View File

@@ -0,0 +1,151 @@
// 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 static and
// virtual method implementations. See the translator.README.txt file in the
// tools directory for more information.
//
#include "libcef_dll/ctocpp/drag_data_ctocpp.h"
#include "libcef_dll/transfer_util.h"
// VIRTUAL METHODS - Body may be edited by hand.
bool CefDragDataCToCpp::IsLink()
{
if (CEF_MEMBER_MISSING(struct_, is_link))
return false;
return struct_->is_link(struct_) ? true : false;
}
bool CefDragDataCToCpp::IsFragment()
{
if (CEF_MEMBER_MISSING(struct_, is_fragment))
return false;
return struct_->is_fragment(struct_) ? true : false;
}
bool CefDragDataCToCpp::IsFile()
{
if (CEF_MEMBER_MISSING(struct_, is_file))
return false;
return struct_->is_file(struct_) ? true : false;
}
CefString CefDragDataCToCpp::GetLinkURL()
{
CefString str;
if (CEF_MEMBER_MISSING(struct_, get_link_url))
return str;
cef_string_userfree_t strPtr = struct_->get_link_url(struct_);
str.AttachToUserFree(strPtr);
return str;
}
CefString CefDragDataCToCpp::GetLinkTitle()
{
CefString str;
if (CEF_MEMBER_MISSING(struct_, get_link_title))
return str;
cef_string_userfree_t strPtr = struct_->get_link_title(struct_);
str.AttachToUserFree(strPtr);
return str;
}
CefString CefDragDataCToCpp::GetLinkMetadata()
{
CefString str;
if (CEF_MEMBER_MISSING(struct_, get_link_metadata))
return str;
cef_string_userfree_t strPtr = struct_->get_link_metadata(struct_);
str.AttachToUserFree(strPtr);
return str;
}
CefString CefDragDataCToCpp::GetFragmentText()
{
CefString str;
if (CEF_MEMBER_MISSING(struct_, get_fragment_text))
return str;
cef_string_userfree_t strPtr = struct_->get_fragment_text(struct_);
str.AttachToUserFree(strPtr);
return str;
}
CefString CefDragDataCToCpp::GetFragmentHtml()
{
CefString str;
if (CEF_MEMBER_MISSING(struct_, get_fragment_html))
return str;
cef_string_userfree_t strPtr = struct_->get_fragment_html(struct_);
str.AttachToUserFree(strPtr);
return str;
}
CefString CefDragDataCToCpp::GetFragmentBaseURL()
{
CefString str;
if (CEF_MEMBER_MISSING(struct_, get_fragment_base_url))
return str;
cef_string_userfree_t strPtr = struct_->get_fragment_base_url(struct_);
str.AttachToUserFree(strPtr);
return str;
}
CefString CefDragDataCToCpp::GetFileExtension()
{
CefString str;
if (CEF_MEMBER_MISSING(struct_, get_file_extension))
return str;
cef_string_userfree_t strPtr = struct_->get_file_extension(struct_);
str.AttachToUserFree(strPtr);
return str;
}
CefString CefDragDataCToCpp::GetFileName()
{
CefString str;
if (CEF_MEMBER_MISSING(struct_, get_file_name))
return str;
cef_string_userfree_t strPtr = struct_->get_file_name(struct_);
str.AttachToUserFree(strPtr);
return str;
}
bool CefDragDataCToCpp::GetFileNames(std::vector<CefString>& names)
{
if (CEF_MEMBER_MISSING(struct_, get_file_names))
return false;
cef_string_list_t list = cef_string_list_alloc();
if(struct_->get_file_names(struct_, list)) {
transfer_string_list_contents(list, names);
cef_string_list_free(list);
return true;
}
return false;
}
#ifndef NDEBUG
template<> long CefCToCpp<CefDragDataCToCpp, CefDragData,
cef_drag_data_t>::DebugObjCt = 0;
#endif

View File

@@ -0,0 +1,50 @@
// 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_CTOCPP_H
#define _DRAGDATA_CTOCPP_H
#ifndef USING_CEF_SHARED
#pragma message("Warning: "__FILE__" may be accessed wrapper-side only")
#else // USING_CEF_SHARED
#include "include/cef.h"
#include "include/cef_capi.h"
#include "libcef_dll/ctocpp/ctocpp.h"
// Wrap a C structure with a C++ class.
// This class may be instantiated and accessed wrapper-side only.
class CefDragDataCToCpp
: public CefCToCpp<CefDragDataCToCpp, CefDragData, cef_drag_data_t>
{
public:
CefDragDataCToCpp(cef_drag_data_t* str)
: CefCToCpp<CefDragDataCToCpp, CefDragData, cef_drag_data_t>(str) {}
virtual ~CefDragDataCToCpp() {}
// CefDragData methods
virtual bool IsLink() OVERRIDE;
virtual bool IsFragment() OVERRIDE;
virtual bool IsFile() OVERRIDE;
virtual CefString GetLinkURL() OVERRIDE;
virtual CefString GetLinkTitle() OVERRIDE;
virtual CefString GetLinkMetadata() OVERRIDE;
virtual CefString GetFragmentText() OVERRIDE;
virtual CefString GetFragmentHtml() OVERRIDE;
virtual CefString GetFragmentBaseURL() OVERRIDE;
virtual CefString GetFileExtension() OVERRIDE;
virtual CefString GetFileName() OVERRIDE;
virtual bool GetFileNames(std::vector<CefString>& names) OVERRIDE;
};
#endif // USING_CEF_SHARED
#endif // _DRAGDATA_CTOCPP_H

View File

@@ -0,0 +1,45 @@
// 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 static and
// virtual method implementations. See the translator.README.txt file in the
// tools directory for more information.
//
#include "libcef_dll/cpptoc/browser_cpptoc.h"
#include "libcef_dll/cpptoc/drag_data_cpptoc.h"
#include "libcef_dll/ctocpp/drag_handler_ctocpp.h"
// VIRTUAL METHODS - Body may be edited by hand.
bool CefDragHandlerCToCpp::OnDragStart(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefDragData> dragData, DragOperationsMask mask)
{
if (CEF_MEMBER_MISSING(struct_, on_drag_start))
return false;
return struct_->on_drag_start(struct_, CefBrowserCppToC::Wrap(browser),
CefDragDataCppToC::Wrap(dragData), mask) ? true : false;
}
bool CefDragHandlerCToCpp::OnDragEnter(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefDragData> dragData, DragOperationsMask mask)
{
if (CEF_MEMBER_MISSING(struct_, on_drag_enter))
return false;
return struct_->on_drag_enter(struct_, CefBrowserCppToC::Wrap(browser),
CefDragDataCppToC::Wrap(dragData), mask) ? true : false;
}
#ifndef NDEBUG
template<> long CefCToCpp<CefDragHandlerCToCpp, CefDragHandler,
cef_drag_handler_t>::DebugObjCt = 0;
#endif

View File

@@ -0,0 +1,43 @@
// 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_CTOCPP_H
#define _DRAGHANDLER_CTOCPP_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/ctocpp/ctocpp.h"
// Wrap a C structure with a C++ class.
// This class may be instantiated and accessed DLL-side only.
class CefDragHandlerCToCpp
: public CefCToCpp<CefDragHandlerCToCpp, CefDragHandler, cef_drag_handler_t>
{
public:
CefDragHandlerCToCpp(cef_drag_handler_t* str)
: CefCToCpp<CefDragHandlerCToCpp, CefDragHandler, cef_drag_handler_t>(
str) {}
virtual ~CefDragHandlerCToCpp() {}
// CefDragHandler methods
virtual bool OnDragStart(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefDragData> dragData, DragOperationsMask mask) OVERRIDE;
virtual bool OnDragEnter(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefDragData> dragData, DragOperationsMask mask) OVERRIDE;
};
#endif // BUILDING_CEF_SHARED
#endif // _DRAGHANDLER_CTOCPP_H