- Add CefDragHandler to support examination of drag data and cancellation of drag requests (issue #297).

- Mac: Fix dragging of URLs by providing a default image if no drag image is supplied.

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@279 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt
2011-08-22 01:31:55 +00:00
parent 88a46e0b44
commit 1b1255c92d
26 changed files with 1192 additions and 30 deletions

View File

@@ -65,6 +65,7 @@ class CefDOMEventListener;
class CefDOMNode;
class CefDOMVisitor;
class CefDownloadHandler;
class CefDragData;
class CefFrame;
class CefPostData;
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.
///
@@ -1619,6 +1654,12 @@ public:
///
/*--cef()--*/
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) {}
};
///
// 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

View File

@@ -1335,6 +1335,38 @@ typedef struct _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.
///
@@ -1415,6 +1447,12 @@ typedef struct _cef_client_t
struct _cef_render_handler_t* (CEF_CALLBACK *get_render_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);
} cef_client_t;
@@ -3190,6 +3228,97 @@ typedef struct _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
}
#endif

View File

@@ -550,6 +550,23 @@ enum cef_handler_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.
///