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:
10
cef.gyp
10
cef.gyp
@ -330,6 +330,8 @@
|
|||||||
'libcef_dll/cpptoc/domevent_cpptoc.h',
|
'libcef_dll/cpptoc/domevent_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/domnode_cpptoc.cc',
|
'libcef_dll/cpptoc/domnode_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/domnode_cpptoc.h',
|
'libcef_dll/cpptoc/domnode_cpptoc.h',
|
||||||
|
'libcef_dll/cpptoc/drag_data_cpptoc.cc',
|
||||||
|
'libcef_dll/cpptoc/drag_data_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/frame_cpptoc.cc',
|
'libcef_dll/cpptoc/frame_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/frame_cpptoc.h',
|
'libcef_dll/cpptoc/frame_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/post_data_cpptoc.cc',
|
'libcef_dll/cpptoc/post_data_cpptoc.cc',
|
||||||
@ -371,6 +373,8 @@
|
|||||||
'libcef_dll/ctocpp/domvisitor_ctocpp.h',
|
'libcef_dll/ctocpp/domvisitor_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/download_handler_ctocpp.cc',
|
'libcef_dll/ctocpp/download_handler_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/download_handler_ctocpp.h',
|
'libcef_dll/ctocpp/download_handler_ctocpp.h',
|
||||||
|
'libcef_dll/ctocpp/drag_handler_ctocpp.cc',
|
||||||
|
'libcef_dll/ctocpp/drag_handler_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/find_handler_ctocpp.cc',
|
'libcef_dll/ctocpp/find_handler_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/find_handler_ctocpp.h',
|
'libcef_dll/ctocpp/find_handler_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/focus_handler_ctocpp.cc',
|
'libcef_dll/ctocpp/focus_handler_ctocpp.cc',
|
||||||
@ -483,6 +487,8 @@
|
|||||||
'libcef_dll/cpptoc/domvisitor_cpptoc.h',
|
'libcef_dll/cpptoc/domvisitor_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/download_handler_cpptoc.cc',
|
'libcef_dll/cpptoc/download_handler_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/download_handler_cpptoc.h',
|
'libcef_dll/cpptoc/download_handler_cpptoc.h',
|
||||||
|
'libcef_dll/cpptoc/drag_handler_cpptoc.cc',
|
||||||
|
'libcef_dll/cpptoc/drag_handler_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/find_handler_cpptoc.cc',
|
'libcef_dll/cpptoc/find_handler_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/find_handler_cpptoc.h',
|
'libcef_dll/cpptoc/find_handler_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/focus_handler_cpptoc.cc',
|
'libcef_dll/cpptoc/focus_handler_cpptoc.cc',
|
||||||
@ -530,6 +536,8 @@
|
|||||||
'libcef_dll/ctocpp/domevent_ctocpp.h',
|
'libcef_dll/ctocpp/domevent_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/domnode_ctocpp.cc',
|
'libcef_dll/ctocpp/domnode_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/domnode_ctocpp.h',
|
'libcef_dll/ctocpp/domnode_ctocpp.h',
|
||||||
|
'libcef_dll/ctocpp/drag_data_ctocpp.cc',
|
||||||
|
'libcef_dll/ctocpp/drag_data_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/frame_ctocpp.cc',
|
'libcef_dll/ctocpp/frame_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/frame_ctocpp.h',
|
'libcef_dll/ctocpp/frame_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/post_data_ctocpp.cc',
|
'libcef_dll/ctocpp/post_data_ctocpp.cc',
|
||||||
@ -688,6 +696,8 @@
|
|||||||
'libcef/cef_thread.h',
|
'libcef/cef_thread.h',
|
||||||
'libcef/cef_time.cc',
|
'libcef/cef_time.cc',
|
||||||
'libcef/cef_time_util.h',
|
'libcef/cef_time_util.h',
|
||||||
|
'libcef/drag_data_impl.cc',
|
||||||
|
'libcef/drag_data_impl.h',
|
||||||
'libcef/drag_download_file.cc',
|
'libcef/drag_download_file.cc',
|
||||||
'libcef/drag_download_file.h',
|
'libcef/drag_download_file.h',
|
||||||
'libcef/drag_download_util.cc',
|
'libcef/drag_download_util.cc',
|
||||||
|
125
include/cef.h
125
include/cef.h
@ -65,6 +65,7 @@ class CefDOMEventListener;
|
|||||||
class CefDOMNode;
|
class CefDOMNode;
|
||||||
class CefDOMVisitor;
|
class CefDOMVisitor;
|
||||||
class CefDownloadHandler;
|
class CefDownloadHandler;
|
||||||
|
class CefDragData;
|
||||||
class CefFrame;
|
class CefFrame;
|
||||||
class CefPostData;
|
class CefPostData;
|
||||||
class CefPostDataElement;
|
class CefPostDataElement;
|
||||||
@ -1541,6 +1542,40 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
// 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 the browser window initiates a drag event. |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 OnDragStart(CefRefPtr<CefBrowser> browser,
|
||||||
|
CefRefPtr<CefDragData> dragData,
|
||||||
|
DragOperationsMask mask) { return false; }
|
||||||
|
|
||||||
|
///
|
||||||
|
// 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<CefBrowser> browser,
|
||||||
|
CefRefPtr<CefDragData> dragData,
|
||||||
|
DragOperationsMask mask) { return false; }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Implement this interface to provide handler implementations.
|
// Implement this interface to provide handler implementations.
|
||||||
///
|
///
|
||||||
@ -1619,6 +1654,12 @@ public:
|
|||||||
///
|
///
|
||||||
/*--cef()--*/
|
/*--cef()--*/
|
||||||
virtual CefRefPtr<CefRenderHandler> GetRenderHandler() { return NULL; }
|
virtual CefRefPtr<CefRenderHandler> GetRenderHandler() { return NULL; }
|
||||||
|
|
||||||
|
///
|
||||||
|
// Return the handler for drag events.
|
||||||
|
///
|
||||||
|
/*--cef()--*/
|
||||||
|
virtual CefRefPtr<CefDragHandler> GetDragHandler() { return NULL; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -3391,4 +3432,88 @@ public:
|
|||||||
virtual void Drain(CefRefPtr<CefStreamReader>& remainder) {}
|
virtual void Drain(CefRefPtr<CefStreamReader>& remainder) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
// 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 extension of the file being dragged out of the browser window.
|
||||||
|
///
|
||||||
|
/*--cef()--*/
|
||||||
|
virtual CefString GetFileExtension() =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<CefString>& names) =0;
|
||||||
|
};
|
||||||
|
|
||||||
#endif // _CEF_H
|
#endif // _CEF_H
|
||||||
|
@ -1335,6 +1335,38 @@ typedef struct _cef_render_handler_t
|
|||||||
} cef_render_handler_t;
|
} cef_render_handler_t;
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
// 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 the browser window initiates a drag event. |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_start)(struct _cef_drag_handler_t* self,
|
||||||
|
struct _cef_browser_t* browser, struct _cef_drag_data_t* dragData,
|
||||||
|
enum cef_drag_operations_mask_t mask);
|
||||||
|
|
||||||
|
///
|
||||||
|
// 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;
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Implement this structure to provide handler implementations.
|
// Implement this structure to provide handler implementations.
|
||||||
///
|
///
|
||||||
@ -1415,6 +1447,12 @@ typedef struct _cef_client_t
|
|||||||
struct _cef_render_handler_t* (CEF_CALLBACK *get_render_handler)(
|
struct _cef_render_handler_t* (CEF_CALLBACK *get_render_handler)(
|
||||||
struct _cef_client_t* self);
|
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);
|
||||||
|
|
||||||
} cef_client_t;
|
} cef_client_t;
|
||||||
|
|
||||||
|
|
||||||
@ -3190,6 +3228,97 @@ typedef struct _cef_content_filter_t
|
|||||||
} cef_content_filter_t;
|
} cef_content_filter_t;
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
// Structure used to represent drag data. The functions of this structure may be
|
||||||
|
// called on any thread.
|
||||||
|
///
|
||||||
|
typedef struct _cef_drag_data_t
|
||||||
|
{
|
||||||
|
// Base structure.
|
||||||
|
cef_base_t base;
|
||||||
|
|
||||||
|
///
|
||||||
|
// Returns true (1) if the drag data is a link.
|
||||||
|
///
|
||||||
|
int (CEF_CALLBACK *is_link)(struct _cef_drag_data_t* self);
|
||||||
|
|
||||||
|
///
|
||||||
|
// Returns true (1) if the drag data is a text or html fragment.
|
||||||
|
///
|
||||||
|
int (CEF_CALLBACK *is_fragment)(struct _cef_drag_data_t* self);
|
||||||
|
|
||||||
|
///
|
||||||
|
// Returns true (1) if the drag data is a file.
|
||||||
|
///
|
||||||
|
int (CEF_CALLBACK *is_file)(struct _cef_drag_data_t* self);
|
||||||
|
|
||||||
|
///
|
||||||
|
// Return the link URL that is being dragged.
|
||||||
|
///
|
||||||
|
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||||
|
cef_string_userfree_t (CEF_CALLBACK *get_link_url)(
|
||||||
|
struct _cef_drag_data_t* self);
|
||||||
|
|
||||||
|
///
|
||||||
|
// Return the title associated with the link being dragged.
|
||||||
|
///
|
||||||
|
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||||
|
cef_string_userfree_t (CEF_CALLBACK *get_link_title)(
|
||||||
|
struct _cef_drag_data_t* self);
|
||||||
|
|
||||||
|
///
|
||||||
|
// Return the metadata, if any, associated with the link being dragged.
|
||||||
|
///
|
||||||
|
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||||
|
cef_string_userfree_t (CEF_CALLBACK *get_link_metadata)(
|
||||||
|
struct _cef_drag_data_t* self);
|
||||||
|
|
||||||
|
///
|
||||||
|
// Return the plain text fragment that is being dragged.
|
||||||
|
///
|
||||||
|
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||||
|
cef_string_userfree_t (CEF_CALLBACK *get_fragment_text)(
|
||||||
|
struct _cef_drag_data_t* self);
|
||||||
|
|
||||||
|
///
|
||||||
|
// Return the text/html fragment that is being dragged.
|
||||||
|
///
|
||||||
|
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||||
|
cef_string_userfree_t (CEF_CALLBACK *get_fragment_html)(
|
||||||
|
struct _cef_drag_data_t* self);
|
||||||
|
|
||||||
|
///
|
||||||
|
// Return the base URL that the fragment came from. This value is used for
|
||||||
|
// resolving relative URLs and may be NULL.
|
||||||
|
///
|
||||||
|
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||||
|
cef_string_userfree_t (CEF_CALLBACK *get_fragment_base_url)(
|
||||||
|
struct _cef_drag_data_t* self);
|
||||||
|
|
||||||
|
///
|
||||||
|
// Return the extension of the file being dragged out of the browser window.
|
||||||
|
///
|
||||||
|
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||||
|
cef_string_userfree_t (CEF_CALLBACK *get_file_extension)(
|
||||||
|
struct _cef_drag_data_t* self);
|
||||||
|
|
||||||
|
///
|
||||||
|
// Return the name of the file being dragged out of the browser window.
|
||||||
|
///
|
||||||
|
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||||
|
cef_string_userfree_t (CEF_CALLBACK *get_file_name)(
|
||||||
|
struct _cef_drag_data_t* self);
|
||||||
|
|
||||||
|
///
|
||||||
|
// Retrieve the list of file names that are being dragged into the browser
|
||||||
|
// window.
|
||||||
|
///
|
||||||
|
int (CEF_CALLBACK *get_file_names)(struct _cef_drag_data_t* self,
|
||||||
|
cef_string_list_t names);
|
||||||
|
|
||||||
|
} cef_drag_data_t;
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -550,6 +550,23 @@ enum cef_handler_errorcode_t
|
|||||||
ERR_INSECURE_RESPONSE = -501,
|
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.
|
// V8 access control values.
|
||||||
///
|
///
|
||||||
|
@ -15,6 +15,10 @@ class WebFrame;
|
|||||||
class WebView;
|
class WebView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(OS_MACOSX)
|
||||||
|
class FilePath;
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace webkit_glue {
|
namespace webkit_glue {
|
||||||
|
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
@ -28,6 +32,7 @@ BOOL SaveBitmapToFile(HBITMAP hBmp, HDC hDC, LPCTSTR file, LPBYTE lpBits);
|
|||||||
|
|
||||||
#if defined(OS_MACOSX)
|
#if defined(OS_MACOSX)
|
||||||
void InitializeDataPak();
|
void InitializeDataPak();
|
||||||
|
FilePath GetResourcesFilePath();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Text encoding objects must be initialized on the main thread.
|
// Text encoding objects must be initialized on the main thread.
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include "browser_webview_delegate.h"
|
#include "browser_webview_delegate.h"
|
||||||
#import "browser_webview_mac.h"
|
#import "browser_webview_mac.h"
|
||||||
#include "browser_impl.h"
|
#include "browser_impl.h"
|
||||||
|
#include "drag_data_impl.h"
|
||||||
#import "include/cef_application_mac.h"
|
#import "include/cef_application_mac.h"
|
||||||
|
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
@ -138,6 +139,21 @@ void BrowserWebViewDelegate::startDragging(const WebDragData& data,
|
|||||||
if (!view)
|
if (!view)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
WebDropData drop_data(data);
|
||||||
|
|
||||||
|
CefRefPtr<CefClient> client = browser_->GetClient();
|
||||||
|
if (client.get()) {
|
||||||
|
CefRefPtr<CefDragHandler> handler = client->GetDragHandler();
|
||||||
|
if (handler.get()) {
|
||||||
|
CefRefPtr<CefDragData> data(new CefDragDataImpl(drop_data));
|
||||||
|
if (handler->OnDragStart(browser_, data,
|
||||||
|
static_cast<CefDragHandler::DragOperationsMask>(mask))) {
|
||||||
|
browser_->UIT_GetWebView()->dragSourceSystemDragEnded();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// By allowing nested tasks, the code below also allows Close(),
|
// By allowing nested tasks, the code below also allows Close(),
|
||||||
// which would deallocate |this|. The same problem can occur while
|
// which would deallocate |this|. The same problem can occur while
|
||||||
// processing -sendEvent:, so Close() is deferred in that case.
|
// processing -sendEvent:, so Close() is deferred in that case.
|
||||||
@ -148,13 +164,16 @@ void BrowserWebViewDelegate::startDragging(const WebDragData& data,
|
|||||||
// The drag invokes a nested event loop, arrange to continue
|
// The drag invokes a nested event loop, arrange to continue
|
||||||
// processing events.
|
// processing events.
|
||||||
MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current());
|
MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current());
|
||||||
NSDragOperation op_mask = static_cast<NSDragOperation>(mask);
|
|
||||||
|
NSImage* ns_image = nil;
|
||||||
|
if (!image.isNull()) {
|
||||||
const SkBitmap& bitmap = gfx::CGImageToSkBitmap(image.getCGImageRef());
|
const SkBitmap& bitmap = gfx::CGImageToSkBitmap(image.getCGImageRef());
|
||||||
CGColorSpaceRef color_space = base::mac::GetSystemColorSpace();
|
CGColorSpaceRef color_space = base::mac::GetSystemColorSpace();
|
||||||
NSImage* ns_image = gfx::SkBitmapToNSImageWithColorSpace(bitmap, color_space);
|
ns_image = gfx::SkBitmapToNSImageWithColorSpace(bitmap, color_space);
|
||||||
|
}
|
||||||
NSPoint offset = NSPointFromCGPoint(gfx::Point(image_offset).ToCGPoint());
|
NSPoint offset = NSPointFromCGPoint(gfx::Point(image_offset).ToCGPoint());
|
||||||
[view startDragWithDropData:WebDropData(data)
|
[view startDragWithDropData:drop_data
|
||||||
dragOperationMask:op_mask
|
dragOperationMask:static_cast<NSDragOperation>(mask)
|
||||||
image:ns_image
|
image:ns_image
|
||||||
offset:offset];
|
offset:offset];
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include "browser_impl.h"
|
#include "browser_impl.h"
|
||||||
#include "browser_webview_delegate.h"
|
#include "browser_webview_delegate.h"
|
||||||
#include "cef_context.h"
|
#include "cef_context.h"
|
||||||
|
#include "drag_data_impl.h"
|
||||||
#include "web_drop_target_win.h"
|
#include "web_drop_target_win.h"
|
||||||
|
|
||||||
#include <objidl.h>
|
#include <objidl.h>
|
||||||
@ -190,8 +191,23 @@ void BrowserWebViewDelegate::startDragging(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WebDropData drop_data(data);
|
||||||
|
|
||||||
|
CefRefPtr<CefClient> client = browser_->GetClient();
|
||||||
|
if (client.get()) {
|
||||||
|
CefRefPtr<CefDragHandler> handler = client->GetDragHandler();
|
||||||
|
if (handler.get()) {
|
||||||
|
CefRefPtr<CefDragData> data(new CefDragDataImpl(drop_data));
|
||||||
|
if (handler->OnDragStart(browser_, data,
|
||||||
|
static_cast<CefDragHandler::DragOperationsMask>(mask))) {
|
||||||
|
EndDragging();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
drag_delegate_ = new BrowserDragDelegate(this);
|
drag_delegate_ = new BrowserDragDelegate(this);
|
||||||
drag_delegate_->StartDragging(WebDropData(data), mask, image.getSkBitmap(),
|
drag_delegate_->StartDragging(drop_data, mask, image.getSkBitmap(),
|
||||||
image_offset);
|
image_offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -563,8 +579,7 @@ end:
|
|||||||
|
|
||||||
void BrowserWebViewDelegate::RegisterDragDrop() {
|
void BrowserWebViewDelegate::RegisterDragDrop() {
|
||||||
DCHECK(!drop_target_);
|
DCHECK(!drop_target_);
|
||||||
drop_target_ = new WebDropTarget(browser_->UIT_GetWebViewWndHandle(),
|
drop_target_ = new WebDropTarget(browser_);
|
||||||
browser_->UIT_GetWebView());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserWebViewDelegate::RevokeDragDrop() {
|
void BrowserWebViewDelegate::RevokeDragDrop() {
|
||||||
|
78
libcef/drag_data_impl.cc
Normal file
78
libcef/drag_data_impl.cc
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
#include "drag_data_impl.h"
|
||||||
|
|
||||||
|
CefDragDataImpl::CefDragDataImpl(const WebDropData& data)
|
||||||
|
: data_(data)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CefDragDataImpl::IsLink()
|
||||||
|
{
|
||||||
|
return (data_.url.is_valid() && data_.file_extension.empty());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CefDragDataImpl::IsFragment()
|
||||||
|
{
|
||||||
|
return (!data_.url.is_valid() && data_.file_extension.empty() &&
|
||||||
|
data_.filenames.empty());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CefDragDataImpl::IsFile()
|
||||||
|
{
|
||||||
|
return (!data_.file_extension.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_.plain_text;
|
||||||
|
}
|
||||||
|
|
||||||
|
CefString CefDragDataImpl::GetFragmentHtml()
|
||||||
|
{
|
||||||
|
return data_.text_html;
|
||||||
|
}
|
||||||
|
|
||||||
|
CefString CefDragDataImpl::GetFragmentBaseURL()
|
||||||
|
{
|
||||||
|
return data_.html_base_url.spec();
|
||||||
|
}
|
||||||
|
|
||||||
|
CefString CefDragDataImpl::GetFileExtension()
|
||||||
|
{
|
||||||
|
return data_.file_extension;
|
||||||
|
}
|
||||||
|
|
||||||
|
CefString CefDragDataImpl::GetFileName()
|
||||||
|
{
|
||||||
|
return data_.file_description_filename;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CefDragDataImpl::GetFileNames(std::vector<CefString>& names)
|
||||||
|
{
|
||||||
|
if (data_.filenames.empty())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
std::vector<string16>::const_iterator it = data_.filenames.begin();
|
||||||
|
for (; it != data_.filenames.end(); ++it)
|
||||||
|
names.push_back(*it);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
36
libcef/drag_data_impl.h
Normal file
36
libcef/drag_data_impl.h
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
#ifndef _DRAG_DATA_IMPL_H
|
||||||
|
#define _DRAG_DATA_IMPL_H
|
||||||
|
|
||||||
|
#include "../include/cef.h"
|
||||||
|
#include "webkit/glue/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 GetFileExtension();
|
||||||
|
virtual CefString GetFileName();
|
||||||
|
virtual bool GetFileNames(std::vector<CefString>& names);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
WebDropData data_;
|
||||||
|
|
||||||
|
IMPLEMENT_REFCOUNTING(CefDragDataImpl);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // _DRAG_DATA_IMPL_H
|
@ -4,6 +4,7 @@
|
|||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#include "browser_impl.h"
|
#include "browser_impl.h"
|
||||||
|
#include "browser_webkit_glue.h"
|
||||||
#import "browser_webview_mac.h"
|
#import "browser_webview_mac.h"
|
||||||
#include "drag_download_util.h"
|
#include "drag_download_util.h"
|
||||||
#include "download_util.h"
|
#include "download_util.h"
|
||||||
@ -140,6 +141,14 @@ void PromiseWriterTask::Run() {
|
|||||||
dropData_.reset(new WebDropData(*dropData));
|
dropData_.reset(new WebDropData(*dropData));
|
||||||
DCHECK(dropData_.get());
|
DCHECK(dropData_.get());
|
||||||
|
|
||||||
|
if (image == nil) {
|
||||||
|
// No drag image was provided so create one.
|
||||||
|
FilePath path = webkit_glue::GetResourcesFilePath();
|
||||||
|
path = path.AppendASCII("urlIcon.png");
|
||||||
|
image = [[NSImage alloc]
|
||||||
|
initWithContentsOfFile:SysUTF8ToNSString(path.value())];
|
||||||
|
}
|
||||||
|
|
||||||
dragImage_.reset([image retain]);
|
dragImage_.reset([image retain]);
|
||||||
imageOffset_ = offset;
|
imageOffset_ = offset;
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include "browser_impl.h"
|
#include "browser_impl.h"
|
||||||
#import "browser_webview_mac.h"
|
#import "browser_webview_mac.h"
|
||||||
#include "cef_context.h"
|
#include "cef_context.h"
|
||||||
|
#include "drag_data_impl.h"
|
||||||
#import "web_drop_target_mac.h"
|
#import "web_drop_target_mac.h"
|
||||||
#import "web_drag_utils_mac.h"
|
#import "web_drag_utils_mac.h"
|
||||||
|
|
||||||
@ -30,8 +31,10 @@ using WebKit::WebView;
|
|||||||
// drag&drop messages to WebCore and handle navigation on a successful drop
|
// drag&drop messages to WebCore and handle navigation on a successful drop
|
||||||
// (if necessary).
|
// (if necessary).
|
||||||
- (id)initWithWebView:(BrowserWebView*)view {
|
- (id)initWithWebView:(BrowserWebView*)view {
|
||||||
if ((self = [super init]))
|
if ((self = [super init])) {
|
||||||
view_ = view;
|
view_ = view;
|
||||||
|
canceled_ = false;
|
||||||
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,17 +89,34 @@ using WebKit::WebView;
|
|||||||
WebView* webview = view_.browser->UIT_GetWebView();
|
WebView* webview = view_.browser->UIT_GetWebView();
|
||||||
|
|
||||||
// Fill out a WebDropData from pasteboard.
|
// Fill out a WebDropData from pasteboard.
|
||||||
WebDropData data;
|
WebDropData drop_data;
|
||||||
[self populateWebDropData:&data fromPasteboard:[info draggingPasteboard]];
|
[self populateWebDropData:&drop_data
|
||||||
|
fromPasteboard:[info draggingPasteboard]];
|
||||||
|
|
||||||
|
NSDragOperation mask = [info draggingSourceOperationMask];
|
||||||
|
|
||||||
|
canceled_ = false;
|
||||||
|
|
||||||
|
CefRefPtr<CefClient> client = view_.browser->GetClient();
|
||||||
|
if (client.get()) {
|
||||||
|
CefRefPtr<CefDragHandler> handler = client->GetDragHandler();
|
||||||
|
if (handler.get()) {
|
||||||
|
CefRefPtr<CefDragData> data(new CefDragDataImpl(drop_data));
|
||||||
|
if (handler->OnDragEnter(view_.browser, data,
|
||||||
|
static_cast<CefDragHandler::DragOperationsMask>(mask))) {
|
||||||
|
canceled_ = true;
|
||||||
|
return NSDragOperationNone;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Create the appropriate mouse locations for WebCore. The draggingLocation
|
// Create the appropriate mouse locations for WebCore. The draggingLocation
|
||||||
// is in window coordinates. Both need to be flipped.
|
// is in window coordinates. Both need to be flipped.
|
||||||
NSPoint windowPoint = [info draggingLocation];
|
NSPoint windowPoint = [info draggingLocation];
|
||||||
NSPoint viewPoint = [self flipWindowPointToView:windowPoint view:view];
|
NSPoint viewPoint = [self flipWindowPointToView:windowPoint view:view];
|
||||||
NSPoint screenPoint = [self flipWindowPointToScreen:windowPoint view:view];
|
NSPoint screenPoint = [self flipWindowPointToScreen:windowPoint view:view];
|
||||||
NSDragOperation mask = [info draggingSourceOperationMask];
|
|
||||||
WebDragOperation op =
|
WebDragOperation op =
|
||||||
webview->dragTargetDragEnter(data.ToDragData(),
|
webview->dragTargetDragEnter(drop_data.ToDragData(),
|
||||||
WebPoint(viewPoint.x, viewPoint.y),
|
WebPoint(viewPoint.x, viewPoint.y),
|
||||||
WebPoint(screenPoint.x, screenPoint.y),
|
WebPoint(screenPoint.x, screenPoint.y),
|
||||||
static_cast<WebDragOperationsMask>(mask));
|
static_cast<WebDragOperationsMask>(mask));
|
||||||
@ -108,6 +128,9 @@ using WebKit::WebView;
|
|||||||
if (current_wvh_ != _Context->current_webviewhost())
|
if (current_wvh_ != _Context->current_webviewhost())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (canceled_)
|
||||||
|
return;
|
||||||
|
|
||||||
WebView* webview = view_.browser->UIT_GetWebView();
|
WebView* webview = view_.browser->UIT_GetWebView();
|
||||||
|
|
||||||
// Nothing to do in the interstitial case.
|
// Nothing to do in the interstitial case.
|
||||||
@ -127,6 +150,9 @@ using WebKit::WebView;
|
|||||||
return NSDragOperationNone;
|
return NSDragOperationNone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (canceled_)
|
||||||
|
return NSDragOperationNone;
|
||||||
|
|
||||||
WebView* webview = view_.browser->UIT_GetWebView();
|
WebView* webview = view_.browser->UIT_GetWebView();
|
||||||
|
|
||||||
// Create the appropriate mouse locations for WebCore. The draggingLocation
|
// Create the appropriate mouse locations for WebCore. The draggingLocation
|
||||||
|
@ -3,9 +3,11 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#include "web_drop_target_win.h"
|
#include "browser_impl.h"
|
||||||
#include "cef_context.h"
|
#include "cef_context.h"
|
||||||
|
#include "drag_data_impl.h"
|
||||||
#include "web_drag_utils_win.h"
|
#include "web_drag_utils_win.h"
|
||||||
|
#include "web_drop_target_win.h"
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <shlobj.h>
|
#include <shlobj.h>
|
||||||
@ -28,6 +30,7 @@ using WebKit::WebDragOperationLink;
|
|||||||
using WebKit::WebDragOperationMove;
|
using WebKit::WebDragOperationMove;
|
||||||
using WebKit::WebDragOperationGeneric;
|
using WebKit::WebDragOperationGeneric;
|
||||||
using WebKit::WebPoint;
|
using WebKit::WebPoint;
|
||||||
|
using WebKit::WebView;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
@ -44,11 +47,12 @@ DWORD GetPreferredDropEffect(DWORD effect) {
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
WebDropTarget::WebDropTarget(HWND source_hwnd, WebKit::WebView* view)
|
WebDropTarget::WebDropTarget(CefBrowserImpl* browser)
|
||||||
: ui::DropTarget(source_hwnd),
|
: ui::DropTarget(browser->UIT_GetWebViewWndHandle()),
|
||||||
view_(view),
|
browser_(browser),
|
||||||
current_wvh_(NULL),
|
current_wvh_(NULL),
|
||||||
drag_cursor_(WebDragOperationNone) {
|
drag_cursor_(WebDragOperationNone),
|
||||||
|
canceled_(false) {
|
||||||
}
|
}
|
||||||
|
|
||||||
WebDropTarget::~WebDropTarget() {
|
WebDropTarget::~WebDropTarget() {
|
||||||
@ -69,15 +73,33 @@ DWORD WebDropTarget::OnDragEnter(IDataObject* data_object,
|
|||||||
if (drop_data.url.is_empty())
|
if (drop_data.url.is_empty())
|
||||||
ui::OSExchangeDataProviderWin::GetPlainTextURL(data_object, &drop_data.url);
|
ui::OSExchangeDataProviderWin::GetPlainTextURL(data_object, &drop_data.url);
|
||||||
|
|
||||||
|
WebKit::WebDragOperationsMask mask =
|
||||||
|
web_drag_utils_win::WinDragOpMaskToWebDragOpMask(effects);
|
||||||
|
|
||||||
|
canceled_ = false;
|
||||||
|
|
||||||
|
CefRefPtr<CefClient> client = browser_->GetClient();
|
||||||
|
if (client.get()) {
|
||||||
|
CefRefPtr<CefDragHandler> handler = client->GetDragHandler();
|
||||||
|
if (handler.get()) {
|
||||||
|
CefRefPtr<CefDragData> data(new CefDragDataImpl(drop_data));
|
||||||
|
if (handler->OnDragEnter(browser_, data,
|
||||||
|
static_cast<CefDragHandler::DragOperationsMask>(mask))) {
|
||||||
|
canceled_ = true;
|
||||||
|
return DROPEFFECT_NONE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
drag_cursor_ = WebDragOperationNone;
|
drag_cursor_ = WebDragOperationNone;
|
||||||
|
|
||||||
POINT client_pt = cursor_position;
|
POINT client_pt = cursor_position;
|
||||||
ScreenToClient(GetHWND(), &client_pt);
|
ScreenToClient(GetHWND(), &client_pt);
|
||||||
WebDragOperation operation = view_->dragTargetDragEnter(
|
WebDragOperation operation = browser_->UIT_GetWebView()->dragTargetDragEnter(
|
||||||
drop_data.ToDragData(),
|
drop_data.ToDragData(),
|
||||||
WebPoint(client_pt.x, client_pt.y),
|
WebPoint(client_pt.x, client_pt.y),
|
||||||
WebPoint(cursor_position.x, cursor_position.y),
|
WebPoint(cursor_position.x, cursor_position.y),
|
||||||
web_drag_utils_win::WinDragOpMaskToWebDragOpMask(effects));
|
mask);
|
||||||
|
|
||||||
return web_drag_utils_win::WebDragOpToWinDragOp(operation);
|
return web_drag_utils_win::WebDragOpToWinDragOp(operation);
|
||||||
}
|
}
|
||||||
@ -90,9 +112,12 @@ DWORD WebDropTarget::OnDragOver(IDataObject* data_object,
|
|||||||
if (current_wvh_ != _Context->current_webviewhost())
|
if (current_wvh_ != _Context->current_webviewhost())
|
||||||
OnDragEnter(data_object, key_state, cursor_position, effects);
|
OnDragEnter(data_object, key_state, cursor_position, effects);
|
||||||
|
|
||||||
|
if (canceled_)
|
||||||
|
return DROPEFFECT_NONE;
|
||||||
|
|
||||||
POINT client_pt = cursor_position;
|
POINT client_pt = cursor_position;
|
||||||
ScreenToClient(GetHWND(), &client_pt);
|
ScreenToClient(GetHWND(), &client_pt);
|
||||||
WebDragOperation operation = view_->dragTargetDragOver(
|
WebDragOperation operation = browser_->UIT_GetWebView()->dragTargetDragOver(
|
||||||
WebPoint(client_pt.x, client_pt.y),
|
WebPoint(client_pt.x, client_pt.y),
|
||||||
WebPoint(cursor_position.x, cursor_position.y),
|
WebPoint(cursor_position.x, cursor_position.y),
|
||||||
web_drag_utils_win::WinDragOpMaskToWebDragOpMask(effects));
|
web_drag_utils_win::WinDragOpMaskToWebDragOpMask(effects));
|
||||||
@ -105,7 +130,10 @@ void WebDropTarget::OnDragLeave(IDataObject* data_object) {
|
|||||||
if (current_wvh_ != _Context->current_webviewhost())
|
if (current_wvh_ != _Context->current_webviewhost())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
view_->dragTargetDragLeave();
|
if (canceled_)
|
||||||
|
return;
|
||||||
|
|
||||||
|
browser_->UIT_GetWebView()->dragTargetDragLeave();
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD WebDropTarget::OnDrop(IDataObject* data_object,
|
DWORD WebDropTarget::OnDrop(IDataObject* data_object,
|
||||||
@ -118,7 +146,7 @@ DWORD WebDropTarget::OnDrop(IDataObject* data_object,
|
|||||||
|
|
||||||
POINT client_pt = cursor_position;
|
POINT client_pt = cursor_position;
|
||||||
ScreenToClient(GetHWND(), &client_pt);
|
ScreenToClient(GetHWND(), &client_pt);
|
||||||
view_->dragTargetDrop(
|
browser_->UIT_GetWebView()->dragTargetDrop(
|
||||||
WebPoint(client_pt.x, client_pt.y),
|
WebPoint(client_pt.x, client_pt.y),
|
||||||
WebPoint(cursor_position.x, cursor_position.y));
|
WebPoint(cursor_position.x, cursor_position.y));
|
||||||
|
|
||||||
|
@ -11,9 +11,7 @@
|
|||||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebDragOperation.h"
|
#include "third_party/WebKit/Source/WebKit/chromium/public/WebDragOperation.h"
|
||||||
#include "ui/base/dragdrop/drop_target.h"
|
#include "ui/base/dragdrop/drop_target.h"
|
||||||
|
|
||||||
namespace WebKit {
|
class CefBrowserImpl;
|
||||||
class WebView;
|
|
||||||
};
|
|
||||||
class WebViewHost;
|
class WebViewHost;
|
||||||
|
|
||||||
// A helper object that provides drop capabilities to a WebView. The
|
// A helper object that provides drop capabilities to a WebView. The
|
||||||
@ -23,7 +21,7 @@ class WebDropTarget : public ui::DropTarget {
|
|||||||
public:
|
public:
|
||||||
// Create a new WebDropTarget associating it with the given HWND and
|
// Create a new WebDropTarget associating it with the given HWND and
|
||||||
// WebView.
|
// WebView.
|
||||||
WebDropTarget(HWND source_hwnd, WebKit::WebView* view);
|
WebDropTarget(CefBrowserImpl* browser);
|
||||||
virtual ~WebDropTarget();
|
virtual ~WebDropTarget();
|
||||||
|
|
||||||
void set_drag_cursor(WebKit::WebDragOperation op) {
|
void set_drag_cursor(WebKit::WebDragOperation op) {
|
||||||
@ -49,8 +47,8 @@ class WebDropTarget : public ui::DropTarget {
|
|||||||
DWORD effect);
|
DWORD effect);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Our associated WebView.
|
// Our associated CefBrowserImpl.
|
||||||
WebKit::WebView* view_;
|
CefBrowserImpl* browser_;
|
||||||
|
|
||||||
// We keep track of the web view host we're dragging over. If it changes
|
// We keep track of the web view host we're dragging over. If it changes
|
||||||
// during a drag, we need to re-send the DragEnter message. WARNING:
|
// during a drag, we need to re-send the DragEnter message. WARNING:
|
||||||
@ -62,6 +60,9 @@ class WebDropTarget : public ui::DropTarget {
|
|||||||
// content area. This can be updated async during a drag operation.
|
// content area. This can be updated async during a drag operation.
|
||||||
WebKit::WebDragOperation drag_cursor_;
|
WebKit::WebDragOperation drag_cursor_;
|
||||||
|
|
||||||
|
// True if the drag has been canceled.
|
||||||
|
bool canceled_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(WebDropTarget);
|
DISALLOW_COPY_AND_ASSIGN(WebDropTarget);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#include "libcef_dll/cpptoc/client_cpptoc.h"
|
#include "libcef_dll/cpptoc/client_cpptoc.h"
|
||||||
#include "libcef_dll/cpptoc/display_handler_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/find_handler_cpptoc.h"
|
||||||
#include "libcef_dll/cpptoc/focus_handler_cpptoc.h"
|
#include "libcef_dll/cpptoc/focus_handler_cpptoc.h"
|
||||||
#include "libcef_dll/cpptoc/jsbinding_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;
|
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.
|
// 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_jsdialog_handler = client_get_jsdialog_handler;
|
||||||
struct_.struct_.get_jsbinding_handler = client_get_jsbinding_handler;
|
struct_.struct_.get_jsbinding_handler = client_get_jsbinding_handler;
|
||||||
struct_.struct_.get_render_handler = client_get_render_handler;
|
struct_.struct_.get_render_handler = client_get_render_handler;
|
||||||
|
struct_.struct_.get_drag_handler = client_get_drag_handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#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
|
||||||
|
|
@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#include "libcef_dll/ctocpp/client_ctocpp.h"
|
#include "libcef_dll/ctocpp/client_ctocpp.h"
|
||||||
#include "libcef_dll/ctocpp/display_handler_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/find_handler_ctocpp.h"
|
||||||
#include "libcef_dll/ctocpp/focus_handler_ctocpp.h"
|
#include "libcef_dll/ctocpp/focus_handler_ctocpp.h"
|
||||||
#include "libcef_dll/ctocpp/jsbinding_handler_ctocpp.h"
|
#include "libcef_dll/ctocpp/jsbinding_handler_ctocpp.h"
|
||||||
@ -175,6 +176,18 @@ CefRefPtr<CefRenderHandler> CefClientCToCpp::GetRenderHandler()
|
|||||||
return NULL;
|
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
|
#ifndef NDEBUG
|
||||||
template<> long CefCToCpp<CefClientCToCpp, CefClient,
|
template<> long CefCToCpp<CefClientCToCpp, CefClient,
|
||||||
|
@ -43,6 +43,7 @@ public:
|
|||||||
virtual CefRefPtr<CefJSDialogHandler> GetJSDialogHandler() OVERRIDE;
|
virtual CefRefPtr<CefJSDialogHandler> GetJSDialogHandler() OVERRIDE;
|
||||||
virtual CefRefPtr<CefJSBindingHandler> GetJSBindingHandler() OVERRIDE;
|
virtual CefRefPtr<CefJSBindingHandler> GetJSBindingHandler() OVERRIDE;
|
||||||
virtual CefRefPtr<CefRenderHandler> GetRenderHandler() OVERRIDE;
|
virtual CefRefPtr<CefRenderHandler> GetRenderHandler() OVERRIDE;
|
||||||
|
virtual CefRefPtr<CefDragHandler> GetDragHandler() OVERRIDE;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // BUILDING_CEF_SHARED
|
#endif // BUILDING_CEF_SHARED
|
||||||
|
151
libcef_dll/ctocpp/drag_data_ctocpp.cc
Normal file
151
libcef_dll/ctocpp/drag_data_ctocpp.cc
Normal 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
|
||||||
|
|
50
libcef_dll/ctocpp/drag_data_ctocpp.h
Normal file
50
libcef_dll/ctocpp/drag_data_ctocpp.h
Normal 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
|
||||||
|
|
45
libcef_dll/ctocpp/drag_handler_ctocpp.cc
Normal file
45
libcef_dll/ctocpp/drag_handler_ctocpp.cc
Normal 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
|
||||||
|
|
43
libcef_dll/ctocpp/drag_handler_ctocpp.h
Normal file
43
libcef_dll/ctocpp/drag_handler_ctocpp.h
Normal 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
|
||||||
|
|
@ -235,6 +235,35 @@ void ClientHandler::OnJSBinding(CefRefPtr<CefBrowser> browser,
|
|||||||
InitBindingTest(browser, frame, object);
|
InitBindingTest(browser, frame, object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ClientHandler::OnDragStart(CefRefPtr<CefBrowser> browser,
|
||||||
|
CefRefPtr<CefDragData> dragData,
|
||||||
|
DragOperationsMask mask)
|
||||||
|
{
|
||||||
|
REQUIRE_UI_THREAD();
|
||||||
|
|
||||||
|
// Forbid dragging of image files.
|
||||||
|
if (dragData->IsFile()) {
|
||||||
|
std::string fileExt = dragData->GetFileExtension();
|
||||||
|
if (fileExt == ".png" || fileExt == ".jpg" || fileExt == ".gif")
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ClientHandler::OnDragEnter(CefRefPtr<CefBrowser> browser,
|
||||||
|
CefRefPtr<CefDragData> dragData,
|
||||||
|
DragOperationsMask mask)
|
||||||
|
{
|
||||||
|
REQUIRE_UI_THREAD();
|
||||||
|
|
||||||
|
// Forbid dragging of link URLs.
|
||||||
|
if (dragData->IsLink())
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void ClientHandler::NotifyDownloadComplete(const CefString& fileName)
|
void ClientHandler::NotifyDownloadComplete(const CefString& fileName)
|
||||||
{
|
{
|
||||||
SetLastDownloadFile(fileName);
|
SetLastDownloadFile(fileName);
|
||||||
|
@ -23,6 +23,7 @@ class ClientHandler : public CefClient,
|
|||||||
public CefDisplayHandler,
|
public CefDisplayHandler,
|
||||||
public CefPrintHandler,
|
public CefPrintHandler,
|
||||||
public CefJSBindingHandler,
|
public CefJSBindingHandler,
|
||||||
|
public CefDragHandler,
|
||||||
public DownloadListener
|
public DownloadListener
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -42,6 +43,8 @@ public:
|
|||||||
{ return this; }
|
{ return this; }
|
||||||
virtual CefRefPtr<CefJSBindingHandler> GetJSBindingHandler() OVERRIDE
|
virtual CefRefPtr<CefJSBindingHandler> GetJSBindingHandler() OVERRIDE
|
||||||
{ return this; }
|
{ return this; }
|
||||||
|
virtual CefRefPtr<CefDragHandler> GetDragHandler() OVERRIDE
|
||||||
|
{ return this; }
|
||||||
|
|
||||||
// CefLifeSpanHandler methods
|
// CefLifeSpanHandler methods
|
||||||
virtual bool OnBeforePopup(CefRefPtr<CefBrowser> parentBrowser,
|
virtual bool OnBeforePopup(CefRefPtr<CefBrowser> parentBrowser,
|
||||||
@ -114,6 +117,14 @@ public:
|
|||||||
CefRefPtr<CefFrame> frame,
|
CefRefPtr<CefFrame> frame,
|
||||||
CefRefPtr<CefV8Value> object) OVERRIDE;
|
CefRefPtr<CefV8Value> object) OVERRIDE;
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
|
||||||
// DownloadListener methods
|
// DownloadListener methods
|
||||||
virtual void NotifyDownloadComplete(const CefString& fileName) OVERRIDE;
|
virtual void NotifyDownloadComplete(const CefString& fileName) OVERRIDE;
|
||||||
virtual void NotifyDownloadError(const CefString& fileName) OVERRIDE;
|
virtual void NotifyDownloadError(const CefString& fileName) OVERRIDE;
|
||||||
|
Reference in New Issue
Block a user