Mac: Add support for disabling HTML5 drag&drop by setting CefBrowserSettings.drag_drop_disabled to true (issue #140).

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@270 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt 2011-08-02 17:30:11 +00:00
parent 7d006a8dd6
commit 0f414c8ac8
4 changed files with 20 additions and 7 deletions

View File

@ -94,6 +94,9 @@ void CefBrowserImpl::UIT_CreateBrowser(const CefString& url)
browserView.browser = this; browserView.browser = this;
window_info_.m_View = browserView; window_info_.m_View = browserView;
if (!settings_.drag_drop_disabled)
[browserView registerDragDrop];
Unlock(); Unlock();
if (newWnd != nil && !window_info_.m_bHidden) { if (newWnd != nil && !window_info_.m_bHidden) {

View File

@ -125,6 +125,11 @@ void BrowserWebViewDelegate::startDragging(const WebDragData& data,
WebDragOperationsMask mask, WebDragOperationsMask mask,
const WebImage& image, const WebImage& image,
const WebPoint& image_offset) { const WebPoint& image_offset) {
if (browser_->settings().drag_drop_disabled) {
browser_->UIT_GetWebView()->dragSourceSystemDragEnded();
return;
}
WebWidgetHost* host = GetWidgetHost(); WebWidgetHost* host = GetWidgetHost();
if (!host) if (!host)
return; return;

View File

@ -40,6 +40,9 @@ struct WebDropData;
- (BOOL)isOpaque; - (BOOL)isOpaque;
- (void)setFrame:(NSRect)frameRect; - (void)setFrame:(NSRect)frameRect;
// Register this WebView as a drag/drop target.
- (void)registerDragDrop;
// Called from BrowserWebViewDelegate::startDragging() to initiate dragging. // Called from BrowserWebViewDelegate::startDragging() to initiate dragging.
- (void)startDragWithDropData:(const WebDropData&)dropData - (void)startDragWithDropData:(const WebDropData&)dropData
dragOperationMask:(NSDragOperation)operationMask dragOperationMask:(NSDragOperation)operationMask

View File

@ -25,13 +25,6 @@
- (id)initWithFrame:(NSRect)frame { - (id)initWithFrame:(NSRect)frame {
self = [super initWithFrame:frame]; self = [super initWithFrame:frame];
if (self) { if (self) {
dropTarget_.reset([[WebDropTarget alloc] initWithWebView:self]);
// Register the view to handle the appropriate drag types.
NSArray* types = [NSArray arrayWithObjects:NSStringPboardType,
NSHTMLPboardType, NSURLPboardType, nil];
[self registerForDraggedTypes:types];
trackingArea_ = trackingArea_ =
[[NSTrackingArea alloc] initWithRect:frame [[NSTrackingArea alloc] initWithRect:frame
options:NSTrackingMouseMoved | options:NSTrackingMouseMoved |
@ -187,6 +180,15 @@
[self setNeedsDisplay:YES]; [self setNeedsDisplay:YES];
} }
- (void)registerDragDrop {
dropTarget_.reset([[WebDropTarget alloc] initWithWebView:self]);
// Register the view to handle the appropriate drag types.
NSArray* types = [NSArray arrayWithObjects:NSStringPboardType,
NSHTMLPboardType, NSURLPboardType, nil];
[self registerForDraggedTypes:types];
}
- (void)startDragWithDropData:(const WebDropData&)dropData - (void)startDragWithDropData:(const WebDropData&)dropData
dragOperationMask:(NSDragOperation)operationMask dragOperationMask:(NSDragOperation)operationMask
image:(NSImage*)image image:(NSImage*)image