diff --git a/cef.gyp b/cef.gyp index 2b0cfa34..a695dd42 100644 --- a/cef.gyp +++ b/cef.gyp @@ -917,6 +917,8 @@ 'libcef/common/command_line_impl.h', 'libcef/common/content_client.cc', 'libcef/common/content_client.h', + 'libcef/common/drag_data_impl.cc', + 'libcef/common/drag_data_impl.h', 'libcef/common/http_header_utils.cc', 'libcef/common/http_header_utils.h', 'libcef/common/main_delegate.cc', diff --git a/cef_paths.gypi b/cef_paths.gypi index 3decdf95..c1936eed 100644 --- a/cef_paths.gypi +++ b/cef_paths.gypi @@ -25,6 +25,8 @@ 'include/cef_dom.h', 'include/cef_download_handler.h', 'include/cef_download_item.h', + 'include/cef_drag_data.h', + 'include/cef_drag_handler.h', 'include/cef_focus_handler.h', 'include/cef_frame.h', 'include/cef_geolocation.h', @@ -72,6 +74,8 @@ 'include/capi/cef_dom_capi.h', 'include/capi/cef_download_handler_capi.h', 'include/capi/cef_download_item_capi.h', + 'include/capi/cef_drag_data_capi.h', + 'include/capi/cef_drag_handler_capi.h', 'include/capi/cef_focus_handler_capi.h', 'include/capi/cef_frame_capi.h', 'include/capi/cef_geolocation_capi.h', @@ -160,6 +164,10 @@ 'libcef_dll/cpptoc/download_item_cpptoc.h', 'libcef_dll/cpptoc/download_item_callback_cpptoc.cc', 'libcef_dll/cpptoc/download_item_callback_cpptoc.h', + 'libcef_dll/cpptoc/drag_data_cpptoc.cc', + 'libcef_dll/cpptoc/drag_data_cpptoc.h', + 'libcef_dll/ctocpp/drag_handler_ctocpp.cc', + 'libcef_dll/ctocpp/drag_handler_ctocpp.h', 'libcef_dll/cpptoc/file_dialog_callback_cpptoc.cc', 'libcef_dll/cpptoc/file_dialog_callback_cpptoc.h', 'libcef_dll/ctocpp/focus_handler_ctocpp.cc', @@ -314,6 +322,10 @@ 'libcef_dll/ctocpp/download_item_ctocpp.h', 'libcef_dll/ctocpp/download_item_callback_ctocpp.cc', 'libcef_dll/ctocpp/download_item_callback_ctocpp.h', + 'libcef_dll/ctocpp/drag_data_ctocpp.cc', + 'libcef_dll/ctocpp/drag_data_ctocpp.h', + 'libcef_dll/cpptoc/drag_handler_cpptoc.cc', + 'libcef_dll/cpptoc/drag_handler_cpptoc.h', 'libcef_dll/ctocpp/file_dialog_callback_ctocpp.cc', 'libcef_dll/ctocpp/file_dialog_callback_ctocpp.h', 'libcef_dll/cpptoc/focus_handler_cpptoc.cc', diff --git a/include/capi/cef_client_capi.h b/include/capi/cef_client_capi.h index cdb513d3..c34e61ca 100644 --- a/include/capi/cef_client_capi.h +++ b/include/capi/cef_client_capi.h @@ -81,6 +81,12 @@ typedef struct _cef_client_t { struct _cef_download_handler_t* (CEF_CALLBACK *get_download_handler)( struct _cef_client_t* self); + /// + // Return the handler for drag events. + /// + struct _cef_drag_handler_t* (CEF_CALLBACK *get_drag_handler)( + struct _cef_client_t* self); + /// // Return the handler for focus events. /// diff --git a/include/capi/cef_drag_handler_capi.h b/include/capi/cef_drag_handler_capi.h new file mode 100644 index 00000000..53752adc --- /dev/null +++ b/include/capi/cef_drag_handler_capi.h @@ -0,0 +1,74 @@ +// Copyright (c) 2013 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// 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 CEF_INCLUDE_CAPI_CEF_DRAG_HANDLER_CAPI_H_ +#define CEF_INCLUDE_CAPI_CEF_DRAG_HANDLER_CAPI_H_ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include "include/capi/cef_base_capi.h" + + +/// +// Implement this structure to handle events related to dragging. The functions +// of this structure will be called on the UI thread. +/// +typedef struct _cef_drag_handler_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Called when an external drag event enters the browser window. |dragData| + // contains the drag event data and |mask| represents the type of drag + // operation. Return false (0) for default drag handling behavior or true (1) + // to cancel the drag event. + /// + int (CEF_CALLBACK *on_drag_enter)(struct _cef_drag_handler_t* self, + struct _cef_browser_t* browser, struct _cef_drag_data_t* dragData, + enum cef_drag_operations_mask_t mask); +} cef_drag_handler_t; + + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_CEF_DRAG_HANDLER_CAPI_H_ diff --git a/include/cef_client.h b/include/cef_client.h index dbba4392..d413e0e6 100644 --- a/include/cef_client.h +++ b/include/cef_client.h @@ -43,6 +43,7 @@ #include "include/cef_dialog_handler.h" #include "include/cef_display_handler.h" #include "include/cef_download_handler.h" +#include "include/cef_drag_handler.h" #include "include/cef_focus_handler.h" #include "include/cef_geolocation_handler.h" #include "include/cef_jsdialog_handler.h" @@ -94,6 +95,14 @@ class CefClient : public virtual CefBase { return NULL; } + /// + // Return the handler for drag events. + /// + /*--cef()--*/ + virtual CefRefPtr GetDragHandler() { + return NULL; + } + /// // Return the handler for focus events. /// diff --git a/include/cef_drag_data.h b/include/cef_drag_data.h new file mode 100644 index 00000000..2791262d --- /dev/null +++ b/include/cef_drag_data.h @@ -0,0 +1,120 @@ +// Copyright (c) 2013 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_CEF_DRAG_DATA_H_ +#define CEF_INCLUDE_CEF_DRAG_DATA_H_ +#pragma once + +#include "include/cef_base.h" +#include + +/// +// Class used to represent drag data. The methods of this class may be called +// on any thread. +/// +/*--cef(source=library)--*/ +class CefDragData : public virtual CefBase { + public: + /// + // Returns true if the drag data is a link. + /// + /*--cef()--*/ + virtual bool IsLink() =0; + + /// + // Returns true if the drag data is a text or html fragment. + /// + /*--cef()--*/ + virtual bool IsFragment() =0; + + /// + // Returns true if the drag data is a file. + /// + /*--cef()--*/ + virtual bool IsFile() =0; + + /// + // Return the link URL that is being dragged. + /// + /*--cef()--*/ + virtual CefString GetLinkURL() =0; + + /// + // Return the title associated with the link being dragged. + /// + /*--cef()--*/ + virtual CefString GetLinkTitle() =0; + + /// + // Return the metadata, if any, associated with the link being dragged. + /// + /*--cef()--*/ + virtual CefString GetLinkMetadata() =0; + + /// + // Return the plain text fragment that is being dragged. + /// + /*--cef()--*/ + virtual CefString GetFragmentText() =0; + + /// + // Return the text/html fragment that is being dragged. + /// + /*--cef()--*/ + virtual CefString GetFragmentHtml() =0; + + /// + // Return the base URL that the fragment came from. This value is used for + // resolving relative URLs and may be empty. + /// + /*--cef()--*/ + virtual CefString GetFragmentBaseURL() =0; + + /// + // Return the name of the file being dragged out of the browser window. + /// + /*--cef()--*/ + virtual CefString GetFileName() =0; + + /// + // Retrieve the list of file names that are being dragged into the browser + // window. + /// + /*--cef()--*/ + virtual bool GetFileNames(std::vector& names) =0; +}; + +#endif // CEF_INCLUDE_CEF_DRAG_DATA_H_ diff --git a/include/cef_drag_handler.h b/include/cef_drag_handler.h new file mode 100644 index 00000000..2535f770 --- /dev/null +++ b/include/cef_drag_handler.h @@ -0,0 +1,66 @@ +// Copyright (c) 2013 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_CEF_DRAG_HANDLER_H_ +#define CEF_INCLUDE_CEF_DRAG_HANDLER_H_ +#pragma once + +#include "include/cef_base.h" +#include "include/cef_drag_data.h" +#include "include/cef_browser.h" + +/// +// Implement this interface to handle events related to dragging. The methods of +// this class will be called on the UI thread. +/// +/*--cef(source=client)--*/ +class CefDragHandler : public virtual CefBase { + public: + typedef cef_drag_operations_mask_t DragOperationsMask; + + /// + // Called when an external drag event enters the browser window. |dragData| + // contains the drag event data and |mask| represents the type of drag + // operation. Return false for default drag handling behavior or true to + // cancel the drag event. + /// + /*--cef()--*/ + virtual bool OnDragEnter(CefRefPtr browser, + CefRefPtr dragData, + DragOperationsMask mask) { return false; } +}; + +#endif // CEF_INCLUDE_CEF_DRAG_HANDLER_H_ diff --git a/include/internal/cef_types.h b/include/internal/cef_types.h index 8f97f6ec..9952555a 100644 --- a/include/internal/cef_types.h +++ b/include/internal/cef_types.h @@ -746,6 +746,22 @@ enum cef_errorcode_t { ERR_INSECURE_RESPONSE = -501, }; +/// +// "Verb" of a drag-and-drop operation as negotiated between the source and +// destination. These constants match their equivalents in WebCore's +// DragActions.h and should not be renumbered. +/// +enum cef_drag_operations_mask_t { + DRAG_OPERATION_NONE = 0, + DRAG_OPERATION_COPY = 1, + DRAG_OPERATION_LINK = 2, + DRAG_OPERATION_GENERIC = 4, + DRAG_OPERATION_PRIVATE = 8, + DRAG_OPERATION_MOVE = 16, + DRAG_OPERATION_DELETE = 32, + DRAG_OPERATION_EVERY = UINT_MAX +}; + /// // V8 access control values. /// diff --git a/libcef/browser/browser_host_impl.cc b/libcef/browser/browser_host_impl.cc index 64d77c34..14370fb4 100644 --- a/libcef/browser/browser_host_impl.cc +++ b/libcef/browser/browser_host_impl.cc @@ -23,6 +23,7 @@ #include "libcef/browser/url_request_context_getter_proxy.h" #include "libcef/common/cef_messages.h" #include "libcef/common/cef_switches.h" +#include "libcef/common/drag_data_impl.h" #include "libcef/common/http_header_utils.h" #include "libcef/common/main_delegate.h" #include "libcef/common/process_message_impl.h" @@ -1668,6 +1669,21 @@ void CefBrowserHostImpl::HandleKeyboardEvent( PlatformHandleKeyboardEvent(event); } +bool CefBrowserHostImpl::CanDragEnter( + content::WebContents* source, + const WebDropData& data, + WebKit::WebDragOperationsMask mask) { + CefRefPtr handler = client_->GetDragHandler(); + if (handler.get()) { + CefRefPtr drag_data(new CefDragDataImpl(data)); + if (handler->OnDragEnter(this, drag_data, + static_cast(mask))) { + return false; + } + } + return true; +} + bool CefBrowserHostImpl::ShouldCreateWebContents( content::WebContents* web_contents, int route_id, diff --git a/libcef/browser/browser_host_impl.h b/libcef/browser/browser_host_impl.h index 5092750b..ef714e03 100644 --- a/libcef/browser/browser_host_impl.h +++ b/libcef/browser/browser_host_impl.h @@ -299,6 +299,10 @@ class CefBrowserHostImpl : public CefBrowserHost, virtual void HandleKeyboardEvent( content::WebContents* source, const content::NativeWebKeyboardEvent& event) OVERRIDE; + virtual bool CanDragEnter( + content::WebContents* source, + const WebDropData& data, + WebKit::WebDragOperationsMask operations_allowed) OVERRIDE; virtual bool ShouldCreateWebContents( content::WebContents* web_contents, int route_id, diff --git a/libcef/common/drag_data_impl.cc b/libcef/common/drag_data_impl.cc new file mode 100644 index 00000000..114a2f3c --- /dev/null +++ b/libcef/common/drag_data_impl.cc @@ -0,0 +1,63 @@ +// Copyright (c) 2013 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 "libcef/common/drag_data_impl.h" +#include "base/files/file_path.h" + +CefDragDataImpl::CefDragDataImpl(const WebDropData& data) + : data_(data) { +} + +bool CefDragDataImpl::IsLink() { + return (data_.url.is_valid() && data_.file_description_filename.empty()); +} + +bool CefDragDataImpl::IsFragment() { + return (!data_.url.is_valid() && data_.file_description_filename.empty() && + data_.filenames.empty()); +} + +bool CefDragDataImpl::IsFile() { + return (!data_.file_description_filename.empty() || !data_.filenames.empty()); +} + +CefString CefDragDataImpl::GetLinkURL() { + return data_.url.spec(); +} + +CefString CefDragDataImpl::GetLinkTitle() { + return data_.url_title; +} + +CefString CefDragDataImpl::GetLinkMetadata() { + return data_.download_metadata; +} + +CefString CefDragDataImpl::GetFragmentText() { + return data_.text.is_null() ? CefString() : CefString(data_.text.string()); +} + +CefString CefDragDataImpl::GetFragmentHtml() { + return data_.html.is_null() ? CefString() : CefString(data_.html.string()); +} + +CefString CefDragDataImpl::GetFragmentBaseURL() { + return data_.html_base_url.spec(); +} + +CefString CefDragDataImpl::GetFileName() { + return data_.file_description_filename; +} + +bool CefDragDataImpl::GetFileNames(std::vector& names) { + if (data_.filenames.empty()) + return false; + + std::vector::const_iterator it = + data_.filenames.begin(); + for (; it != data_.filenames.end(); ++it) + names.push_back(it->path); + + return true; +} diff --git a/libcef/common/drag_data_impl.h b/libcef/common/drag_data_impl.h new file mode 100644 index 00000000..b7425578 --- /dev/null +++ b/libcef/common/drag_data_impl.h @@ -0,0 +1,37 @@ +// Copyright (c) 2013 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 CEF_LIBCEF_COMMON_DRAG_DATA_IMPL_H_ +#define CEF_LIBCEF_COMMON_DRAG_DATA_IMPL_H_ +#pragma once + +#include + +#include "include/cef_drag_data.h" +#include "webkit/common/webdropdata.h" + +// Implementation of CefDragData. +class CefDragDataImpl : public CefDragData { + public: + explicit CefDragDataImpl(const WebDropData& data); + + virtual bool IsLink(); + virtual bool IsFragment(); + virtual bool IsFile(); + virtual CefString GetLinkURL(); + virtual CefString GetLinkTitle(); + virtual CefString GetLinkMetadata(); + virtual CefString GetFragmentText(); + virtual CefString GetFragmentHtml(); + virtual CefString GetFragmentBaseURL(); + virtual CefString GetFileName(); + virtual bool GetFileNames(std::vector& names); + + protected: + WebDropData data_; + + IMPLEMENT_REFCOUNTING(CefDragDataImpl); +}; + +#endif // CEF_LIBCEF_COMMON_DRAG_DATA_IMPL_H_ diff --git a/libcef_dll/cpptoc/client_cpptoc.cc b/libcef_dll/cpptoc/client_cpptoc.cc index 5ff86018..6cfe3bc1 100644 --- a/libcef_dll/cpptoc/client_cpptoc.cc +++ b/libcef_dll/cpptoc/client_cpptoc.cc @@ -15,6 +15,7 @@ #include "libcef_dll/cpptoc/dialog_handler_cpptoc.h" #include "libcef_dll/cpptoc/display_handler_cpptoc.h" #include "libcef_dll/cpptoc/download_handler_cpptoc.h" +#include "libcef_dll/cpptoc/drag_handler_cpptoc.h" #include "libcef_dll/cpptoc/focus_handler_cpptoc.h" #include "libcef_dll/cpptoc/geolocation_handler_cpptoc.h" #include "libcef_dll/cpptoc/jsdialog_handler_cpptoc.h" @@ -93,6 +94,22 @@ struct _cef_download_handler_t* CEF_CALLBACK client_get_download_handler( return CefDownloadHandlerCppToC::Wrap(_retval); } +struct _cef_drag_handler_t* CEF_CALLBACK client_get_drag_handler( + struct _cef_client_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefClientCppToC::Get( + self)->GetDragHandler(); + + // Return type: refptr_same + return CefDragHandlerCppToC::Wrap(_retval); +} + struct _cef_focus_handler_t* CEF_CALLBACK client_get_focus_handler( struct _cef_client_t* self) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -257,6 +274,7 @@ CefClientCppToC::CefClientCppToC(CefClient* cls) struct_.struct_.get_dialog_handler = client_get_dialog_handler; struct_.struct_.get_display_handler = client_get_display_handler; struct_.struct_.get_download_handler = client_get_download_handler; + struct_.struct_.get_drag_handler = client_get_drag_handler; struct_.struct_.get_focus_handler = client_get_focus_handler; struct_.struct_.get_geolocation_handler = client_get_geolocation_handler; struct_.struct_.get_jsdialog_handler = client_get_jsdialog_handler; diff --git a/libcef_dll/cpptoc/drag_data_cpptoc.cc b/libcef_dll/cpptoc/drag_data_cpptoc.cc new file mode 100644 index 00000000..1b30d6ce --- /dev/null +++ b/libcef_dll/cpptoc/drag_data_cpptoc.cc @@ -0,0 +1,216 @@ +// Copyright (c) 2013 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. If making changes by +// hand only do so within the body of existing method and 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) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefDragDataCppToC::Get(self)->IsLink(); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK drag_data_is_fragment(struct _cef_drag_data_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefDragDataCppToC::Get(self)->IsFragment(); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK drag_data_is_file(struct _cef_drag_data_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefDragDataCppToC::Get(self)->IsFile(); + + // Return type: bool + return _retval; +} + +cef_string_userfree_t CEF_CALLBACK drag_data_get_link_url( + struct _cef_drag_data_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefDragDataCppToC::Get(self)->GetLinkURL(); + + // Return type: string + return _retval.DetachToUserFree(); +} + +cef_string_userfree_t CEF_CALLBACK drag_data_get_link_title( + struct _cef_drag_data_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefDragDataCppToC::Get(self)->GetLinkTitle(); + + // Return type: string + return _retval.DetachToUserFree(); +} + +cef_string_userfree_t CEF_CALLBACK drag_data_get_link_metadata( + struct _cef_drag_data_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefDragDataCppToC::Get(self)->GetLinkMetadata(); + + // Return type: string + return _retval.DetachToUserFree(); +} + +cef_string_userfree_t CEF_CALLBACK drag_data_get_fragment_text( + struct _cef_drag_data_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefDragDataCppToC::Get(self)->GetFragmentText(); + + // Return type: string + return _retval.DetachToUserFree(); +} + +cef_string_userfree_t CEF_CALLBACK drag_data_get_fragment_html( + struct _cef_drag_data_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefDragDataCppToC::Get(self)->GetFragmentHtml(); + + // Return type: string + return _retval.DetachToUserFree(); +} + +cef_string_userfree_t CEF_CALLBACK drag_data_get_fragment_base_url( + struct _cef_drag_data_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefDragDataCppToC::Get(self)->GetFragmentBaseURL(); + + // Return type: string + return _retval.DetachToUserFree(); +} + +cef_string_userfree_t CEF_CALLBACK drag_data_get_file_name( + struct _cef_drag_data_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefDragDataCppToC::Get(self)->GetFileName(); + + // Return type: string + return _retval.DetachToUserFree(); +} + +int CEF_CALLBACK drag_data_get_file_names(struct _cef_drag_data_t* self, + cef_string_list_t names) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: names; type: string_vec_byref + DCHECK(names); + if (!names) + return 0; + + // Translate param: names; type: string_vec_byref + std::vector namesList; + transfer_string_list_contents(names, namesList); + + // Execute + bool _retval = CefDragDataCppToC::Get(self)->GetFileNames( + namesList); + + // Restore param: names; type: string_vec_byref + cef_string_list_clear(names); + transfer_string_list_contents(namesList, names); + + // Return type: bool + return _retval; +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefDragDataCppToC::CefDragDataCppToC(CefDragData* cls) + : CefCppToC(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_name = drag_data_get_file_name; + struct_.struct_.get_file_names = drag_data_get_file_names; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/libcef_dll/cpptoc/drag_data_cpptoc.h b/libcef_dll/cpptoc/drag_data_cpptoc.h new file mode 100644 index 00000000..441d2c53 --- /dev/null +++ b/libcef_dll/cpptoc/drag_data_cpptoc.h @@ -0,0 +1,36 @@ +// Copyright (c) 2013 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_DRAG_DATA_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_DRAG_DATA_CPPTOC_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_drag_data.h" +#include "include/capi/cef_drag_data_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 { + public: + explicit CefDragDataCppToC(CefDragData* cls); + virtual ~CefDragDataCppToC() {} +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_DRAG_DATA_CPPTOC_H_ + diff --git a/libcef_dll/cpptoc/drag_handler_cpptoc.cc b/libcef_dll/cpptoc/drag_handler_cpptoc.cc new file mode 100644 index 00000000..18bae4d9 --- /dev/null +++ b/libcef_dll/cpptoc/drag_handler_cpptoc.cc @@ -0,0 +1,59 @@ +// Copyright (c) 2013 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. If making changes by +// hand only do so within the body of existing method and 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_enter(struct _cef_drag_handler_t* self, + cef_browser_t* browser, cef_drag_data_t* dragData, + enum cef_drag_operations_mask_t mask) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return 0; + // Verify param: dragData; type: refptr_diff + DCHECK(dragData); + if (!dragData) + return 0; + + // Execute + bool _retval = CefDragHandlerCppToC::Get(self)->OnDragEnter( + CefBrowserCToCpp::Wrap(browser), + CefDragDataCToCpp::Wrap(dragData), + mask); + + // Return type: bool + return _retval; +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefDragHandlerCppToC::CefDragHandlerCppToC(CefDragHandler* cls) + : CefCppToC(cls) { + struct_.struct_.on_drag_enter = drag_handler_on_drag_enter; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/libcef_dll/cpptoc/drag_handler_cpptoc.h b/libcef_dll/cpptoc/drag_handler_cpptoc.h new file mode 100644 index 00000000..f93a2860 --- /dev/null +++ b/libcef_dll/cpptoc/drag_handler_cpptoc.h @@ -0,0 +1,37 @@ +// Copyright (c) 2013 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_DRAG_HANDLER_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_DRAG_HANDLER_CPPTOC_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_drag_handler.h" +#include "include/capi/cef_drag_handler_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 { + public: + explicit CefDragHandlerCppToC(CefDragHandler* cls); + virtual ~CefDragHandlerCppToC() {} +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_DRAG_HANDLER_CPPTOC_H_ + diff --git a/libcef_dll/ctocpp/client_ctocpp.cc b/libcef_dll/ctocpp/client_ctocpp.cc index 5cbfcc0b..3d7d634a 100644 --- a/libcef_dll/ctocpp/client_ctocpp.cc +++ b/libcef_dll/ctocpp/client_ctocpp.cc @@ -17,6 +17,7 @@ #include "libcef_dll/ctocpp/dialog_handler_ctocpp.h" #include "libcef_dll/ctocpp/display_handler_ctocpp.h" #include "libcef_dll/ctocpp/download_handler_ctocpp.h" +#include "libcef_dll/ctocpp/drag_handler_ctocpp.h" #include "libcef_dll/ctocpp/focus_handler_ctocpp.h" #include "libcef_dll/ctocpp/geolocation_handler_ctocpp.h" #include "libcef_dll/ctocpp/jsdialog_handler_ctocpp.h" @@ -82,6 +83,19 @@ CefRefPtr CefClientCToCpp::GetDownloadHandler() { return CefDownloadHandlerCToCpp::Wrap(_retval); } +CefRefPtr CefClientCToCpp::GetDragHandler() { + if (CEF_MEMBER_MISSING(struct_, get_drag_handler)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_drag_handler_t* _retval = struct_->get_drag_handler(struct_); + + // Return type: refptr_same + return CefDragHandlerCToCpp::Wrap(_retval); +} + CefRefPtr CefClientCToCpp::GetFocusHandler() { if (CEF_MEMBER_MISSING(struct_, get_focus_handler)) return NULL; diff --git a/libcef_dll/ctocpp/client_ctocpp.h b/libcef_dll/ctocpp/client_ctocpp.h index bf2f4c36..7b6b3dc2 100644 --- a/libcef_dll/ctocpp/client_ctocpp.h +++ b/libcef_dll/ctocpp/client_ctocpp.h @@ -36,6 +36,7 @@ class CefClientCToCpp virtual CefRefPtr GetDialogHandler() OVERRIDE; virtual CefRefPtr GetDisplayHandler() OVERRIDE; virtual CefRefPtr GetDownloadHandler() OVERRIDE; + virtual CefRefPtr GetDragHandler() OVERRIDE; virtual CefRefPtr GetFocusHandler() OVERRIDE; virtual CefRefPtr GetGeolocationHandler() OVERRIDE; virtual CefRefPtr GetJSDialogHandler() OVERRIDE; diff --git a/libcef_dll/ctocpp/drag_data_ctocpp.cc b/libcef_dll/ctocpp/drag_data_ctocpp.cc new file mode 100644 index 00000000..c8b49514 --- /dev/null +++ b/libcef_dll/ctocpp/drag_data_ctocpp.cc @@ -0,0 +1,195 @@ +// Copyright (c) 2013 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. If making changes by +// hand only do so within the body of existing method and function +// 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; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_link(struct_); + + // Return type: bool + return _retval?true:false; +} + +bool CefDragDataCToCpp::IsFragment() { + if (CEF_MEMBER_MISSING(struct_, is_fragment)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_fragment(struct_); + + // Return type: bool + return _retval?true:false; +} + +bool CefDragDataCToCpp::IsFile() { + if (CEF_MEMBER_MISSING(struct_, is_file)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_file(struct_); + + // Return type: bool + return _retval?true:false; +} + +CefString CefDragDataCToCpp::GetLinkURL() { + if (CEF_MEMBER_MISSING(struct_, get_link_url)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_link_url(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +CefString CefDragDataCToCpp::GetLinkTitle() { + if (CEF_MEMBER_MISSING(struct_, get_link_title)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_link_title(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +CefString CefDragDataCToCpp::GetLinkMetadata() { + if (CEF_MEMBER_MISSING(struct_, get_link_metadata)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_link_metadata(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +CefString CefDragDataCToCpp::GetFragmentText() { + if (CEF_MEMBER_MISSING(struct_, get_fragment_text)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_fragment_text(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +CefString CefDragDataCToCpp::GetFragmentHtml() { + if (CEF_MEMBER_MISSING(struct_, get_fragment_html)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_fragment_html(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +CefString CefDragDataCToCpp::GetFragmentBaseURL() { + if (CEF_MEMBER_MISSING(struct_, get_fragment_base_url)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_fragment_base_url(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +CefString CefDragDataCToCpp::GetFileName() { + if (CEF_MEMBER_MISSING(struct_, get_file_name)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_file_name(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +bool CefDragDataCToCpp::GetFileNames(std::vector& names) { + if (CEF_MEMBER_MISSING(struct_, get_file_names)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Translate param: names; type: string_vec_byref + cef_string_list_t namesList = cef_string_list_alloc(); + DCHECK(namesList); + if (namesList) + transfer_string_list_contents(names, namesList); + + // Execute + int _retval = struct_->get_file_names(struct_, + namesList); + + // Restore param:names; type: string_vec_byref + if (namesList) { + names.clear(); + transfer_string_list_contents(namesList, names); + cef_string_list_free(namesList); + } + + // Return type: bool + return _retval?true:false; +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/libcef_dll/ctocpp/drag_data_ctocpp.h b/libcef_dll/ctocpp/drag_data_ctocpp.h new file mode 100644 index 00000000..38d89e27 --- /dev/null +++ b/libcef_dll/ctocpp/drag_data_ctocpp.h @@ -0,0 +1,51 @@ +// Copyright (c) 2013 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_DRAG_DATA_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_DRAG_DATA_CTOCPP_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include +#include "include/cef_drag_data.h" +#include "include/capi/cef_drag_data_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 { + public: + explicit CefDragDataCToCpp(cef_drag_data_t* str) + : CefCToCpp(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 GetFileName() OVERRIDE; + virtual bool GetFileNames(std::vector& names) OVERRIDE; +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_DRAG_DATA_CTOCPP_H_ + diff --git a/libcef_dll/ctocpp/drag_handler_ctocpp.cc b/libcef_dll/ctocpp/drag_handler_ctocpp.cc new file mode 100644 index 00000000..4f6c458b --- /dev/null +++ b/libcef_dll/ctocpp/drag_handler_ctocpp.cc @@ -0,0 +1,51 @@ +// Copyright (c) 2013 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. If making changes by +// hand only do so within the body of existing method and function +// 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::OnDragEnter(CefRefPtr browser, + CefRefPtr dragData, DragOperationsMask mask) { + if (CEF_MEMBER_MISSING(struct_, on_drag_enter)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: browser; type: refptr_diff + DCHECK(browser.get()); + if (!browser.get()) + return false; + // Verify param: dragData; type: refptr_diff + DCHECK(dragData.get()); + if (!dragData.get()) + return false; + + // Execute + int _retval = struct_->on_drag_enter(struct_, + CefBrowserCppToC::Wrap(browser), + CefDragDataCppToC::Wrap(dragData), + mask); + + // Return type: bool + return _retval?true:false; +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/libcef_dll/ctocpp/drag_handler_ctocpp.h b/libcef_dll/ctocpp/drag_handler_ctocpp.h new file mode 100644 index 00000000..31278349 --- /dev/null +++ b/libcef_dll/ctocpp/drag_handler_ctocpp.h @@ -0,0 +1,43 @@ +// Copyright (c) 2013 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_DRAG_HANDLER_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_DRAG_HANDLER_CTOCPP_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_drag_handler.h" +#include "include/capi/cef_drag_handler_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 { + public: + explicit CefDragHandlerCToCpp(cef_drag_handler_t* str) + : CefCToCpp( + str) {} + virtual ~CefDragHandlerCToCpp() {} + + // CefDragHandler methods + virtual bool OnDragEnter(CefRefPtr browser, + CefRefPtr dragData, DragOperationsMask mask) OVERRIDE; +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_DRAG_HANDLER_CTOCPP_H_ + diff --git a/libcef_dll/libcef_dll.cc b/libcef_dll/libcef_dll.cc index 8c40830d..0bfb131e 100644 --- a/libcef_dll/libcef_dll.cc +++ b/libcef_dll/libcef_dll.cc @@ -48,6 +48,7 @@ #include "libcef_dll/cpptoc/dictionary_value_cpptoc.h" #include "libcef_dll/cpptoc/download_item_cpptoc.h" #include "libcef_dll/cpptoc/download_item_callback_cpptoc.h" +#include "libcef_dll/cpptoc/drag_data_cpptoc.h" #include "libcef_dll/cpptoc/file_dialog_callback_cpptoc.h" #include "libcef_dll/cpptoc/frame_cpptoc.h" #include "libcef_dll/cpptoc/geolocation_callback_cpptoc.h" @@ -79,6 +80,7 @@ #include "libcef_dll/ctocpp/dialog_handler_ctocpp.h" #include "libcef_dll/ctocpp/display_handler_ctocpp.h" #include "libcef_dll/ctocpp/download_handler_ctocpp.h" +#include "libcef_dll/ctocpp/drag_handler_ctocpp.h" #include "libcef_dll/ctocpp/focus_handler_ctocpp.h" #include "libcef_dll/ctocpp/geolocation_handler_ctocpp.h" #include "libcef_dll/ctocpp/get_geolocation_callback_ctocpp.h" @@ -196,6 +198,8 @@ CEF_EXPORT void cef_shutdown() { DCHECK_EQ(CefDownloadHandlerCToCpp::DebugObjCt, 0); DCHECK_EQ(CefDownloadItemCallbackCppToC::DebugObjCt, 0); DCHECK_EQ(CefDownloadItemCppToC::DebugObjCt, 0); + DCHECK_EQ(CefDragDataCppToC::DebugObjCt, 0); + DCHECK_EQ(CefDragHandlerCToCpp::DebugObjCt, 0); DCHECK_EQ(CefFileDialogCallbackCppToC::DebugObjCt, 0); DCHECK_EQ(CefFocusHandlerCToCpp::DebugObjCt, 0); DCHECK_EQ(CefFrameCppToC::DebugObjCt, 0); diff --git a/libcef_dll/wrapper/libcef_dll_wrapper.cc b/libcef_dll/wrapper/libcef_dll_wrapper.cc index 9917c175..bdd0464d 100644 --- a/libcef_dll/wrapper/libcef_dll_wrapper.cc +++ b/libcef_dll/wrapper/libcef_dll_wrapper.cc @@ -43,6 +43,7 @@ #include "libcef_dll/cpptoc/dialog_handler_cpptoc.h" #include "libcef_dll/cpptoc/display_handler_cpptoc.h" #include "libcef_dll/cpptoc/download_handler_cpptoc.h" +#include "libcef_dll/cpptoc/drag_handler_cpptoc.h" #include "libcef_dll/cpptoc/focus_handler_cpptoc.h" #include "libcef_dll/cpptoc/geolocation_handler_cpptoc.h" #include "libcef_dll/cpptoc/get_geolocation_callback_cpptoc.h" @@ -83,6 +84,7 @@ #include "libcef_dll/ctocpp/dictionary_value_ctocpp.h" #include "libcef_dll/ctocpp/download_item_ctocpp.h" #include "libcef_dll/ctocpp/download_item_callback_ctocpp.h" +#include "libcef_dll/ctocpp/drag_data_ctocpp.h" #include "libcef_dll/ctocpp/file_dialog_callback_ctocpp.h" #include "libcef_dll/ctocpp/frame_ctocpp.h" #include "libcef_dll/ctocpp/geolocation_callback_ctocpp.h" @@ -188,6 +190,8 @@ CEF_GLOBAL void CefShutdown() { DCHECK_EQ(CefDownloadHandlerCppToC::DebugObjCt, 0); DCHECK_EQ(CefDownloadItemCToCpp::DebugObjCt, 0); DCHECK_EQ(CefDownloadItemCallbackCToCpp::DebugObjCt, 0); + DCHECK_EQ(CefDragDataCToCpp::DebugObjCt, 0); + DCHECK_EQ(CefDragHandlerCppToC::DebugObjCt, 0); DCHECK_EQ(CefFileDialogCallbackCToCpp::DebugObjCt, 0); DCHECK_EQ(CefFocusHandlerCppToC::DebugObjCt, 0); DCHECK_EQ(CefFrameCToCpp::DebugObjCt, 0); diff --git a/tests/cefclient/client_handler.cpp b/tests/cefclient/client_handler.cpp index 28a7f40d..e9f8f067 100644 --- a/tests/cefclient/client_handler.cpp +++ b/tests/cefclient/client_handler.cpp @@ -262,6 +262,18 @@ void ClientHandler::OnDownloadUpdated( } } +bool ClientHandler::OnDragEnter(CefRefPtr browser, + CefRefPtr dragData, + DragOperationsMask mask) { + REQUIRE_UI_THREAD(); + + // Forbid dragging of link URLs. + if (dragData->IsLink()) + return true; + + return false; +} + void ClientHandler::OnRequestGeolocationPermission( CefRefPtr browser, const CefString& requesting_url, diff --git a/tests/cefclient/client_handler.h b/tests/cefclient/client_handler.h index 40c64395..fad023fe 100644 --- a/tests/cefclient/client_handler.h +++ b/tests/cefclient/client_handler.h @@ -24,6 +24,7 @@ class ClientHandler : public CefClient, public CefContextMenuHandler, public CefDisplayHandler, public CefDownloadHandler, + public CefDragHandler, public CefGeolocationHandler, public CefKeyboardHandler, public CefLifeSpanHandler, @@ -70,6 +71,9 @@ class ClientHandler : public CefClient, virtual CefRefPtr GetDownloadHandler() OVERRIDE { return this; } + virtual CefRefPtr GetDragHandler() OVERRIDE { + return this; + } virtual CefRefPtr GetGeolocationHandler() OVERRIDE { return this; } @@ -130,6 +134,11 @@ class ClientHandler : public CefClient, CefRefPtr download_item, CefRefPtr callback) OVERRIDE; + // CefDragHandler methods + virtual bool OnDragEnter(CefRefPtr browser, + CefRefPtr dragData, + DragOperationsMask mask) OVERRIDE; + // CefGeolocationHandler methods virtual void OnRequestGeolocationPermission( CefRefPtr browser,