diff options
author | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-08 03:20:56 +0000 |
---|---|---|
committer | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-08 03:20:56 +0000 |
commit | bde52d9bedc8438405f5a6d15366f712f7dcd144 (patch) | |
tree | bbdd48cbc655039b234c9a54a36812052fab755d /content/browser/web_contents | |
parent | 56f4ebcbfe22129c8ecfd743fea238a7ab3ef81c (diff) | |
download | chromium_src-bde52d9bedc8438405f5a6d15366f712f7dcd144.zip chromium_src-bde52d9bedc8438405f5a6d15366f712f7dcd144.tar.gz chromium_src-bde52d9bedc8438405f5a6d15366f712f7dcd144.tar.bz2 |
Implement WebContentsView::GetDropData for Mac; disable on Aura
I don't know what the appropriate analog is for this UI on Aura, so just disabling it now.
BUG=55584
TBR=jam@chromium.org
Review URL: https://chromiumcodereview.appspot.com/10386014
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@135785 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/web_contents')
4 files changed, 39 insertions, 17 deletions
diff --git a/content/browser/web_contents/web_contents_view_mac.mm b/content/browser/web_contents/web_contents_view_mac.mm index 15c7049..3e2677e 100644 --- a/content/browser/web_contents/web_contents_view_mac.mm +++ b/content/browser/web_contents/web_contents_view_mac.mm @@ -46,6 +46,7 @@ COMPILE_ASSERT_MATCHING_ENUM(DragOperationEvery); - (id)initWithWebContentsViewMac:(WebContentsViewMac*)w; - (void)registerDragTypes; - (void)setCurrentDragOperation:(NSDragOperation)operation; +- (WebDropData*)dropData; - (void)startDragWithDropData:(const WebDropData&)dropData dragOperationMask:(NSDragOperation)operationMask image:(NSImage*)image @@ -248,7 +249,7 @@ void WebContentsViewMac::CancelDragAndCloseTab() { } WebDropData* WebContentsViewMac::GetDropData() const { - return NULL; + return [cocoa_view_ dropData]; } void WebContentsViewMac::UpdateDragCursor(WebDragOperation operation) { @@ -442,6 +443,10 @@ void WebContentsViewMac::CloseTab() { [dragDest_ setCurrentOperation:operation]; } +- (WebDropData*)dropData { + return [dragDest_ currentDropData]; +} + - (WebContentsImpl*)webContents { if (webContentsView_ == NULL) return NULL; diff --git a/content/browser/web_contents/web_drag_dest_gtk.cc b/content/browser/web_contents/web_drag_dest_gtk.cc index 458b33c..c3cf97a 100644 --- a/content/browser/web_contents/web_drag_dest_gtk.cc +++ b/content/browser/web_contents/web_drag_dest_gtk.cc @@ -73,6 +73,8 @@ void WebDragDestGtk::DragLeave() { if (delegate()) delegate()->OnDragLeave(); + + drop_data_.reset(); } gboolean WebDragDestGtk::OnDragMotion(GtkWidget* sender, @@ -240,7 +242,7 @@ void WebDragDestGtk::OnDragLeave(GtkWidget* sender, GdkDragContext* context, // Set |context_| to NULL to make sure we will recognize the next DragMotion // as an enter. context_ = NULL; - drop_data_.reset(); + // When GTK sends us a drag-drop signal, it is shortly (and synchronously) // preceded by a drag-leave. The renderer doesn't like getting the signals // in this order so delay telling it about the drag-leave till we are sure diff --git a/content/browser/web_contents/web_drag_dest_mac.h b/content/browser/web_contents/web_drag_dest_mac.h index 0e22fa0..0340cfd 100644 --- a/content/browser/web_contents/web_drag_dest_mac.h +++ b/content/browser/web_contents/web_drag_dest_mac.h @@ -4,10 +4,11 @@ #import <Cocoa/Cocoa.h> +#include "base/memory/scoped_ptr.h" #include "base/string16.h" +#include "webkit/glue/webdropdata.h" class WebContentsImpl; -struct WebDropData; namespace content { class RenderViewHost; @@ -31,11 +32,14 @@ typedef content::RenderViewHost* RenderViewHostIdentifier; // Updated asynchronously during a drag to tell us whether or not we should // allow the drop. - NSDragOperation current_operation_; + NSDragOperation currentOperation_; // Keep track of the render view host we're dragging over. If it changes // during a drag, we need to re-send the DragEnter message. RenderViewHostIdentifier currentRVH_; + + // The data for the current drag, or NULL if none is in progress. + scoped_ptr<WebDropData> dropData_; } // |contents| is the WebContentsImpl representing this tab, used to communicate @@ -43,6 +47,8 @@ typedef content::RenderViewHost* RenderViewHostIdentifier; // (if necessary). - (id)initWithWebContentsImpl:(WebContentsImpl*)contents; +- (WebDropData*)currentDropData; + - (void)setDragDelegate:(content::WebDragDestDelegate*)delegate; // Sets the current operation negotiated by the source and destination, diff --git a/content/browser/web_contents/web_drag_dest_mac.mm b/content/browser/web_contents/web_drag_dest_mac.mm index 025742d..7ba78b53 100644 --- a/content/browser/web_contents/web_drag_dest_mac.mm +++ b/content/browser/web_contents/web_drag_dest_mac.mm @@ -30,6 +30,10 @@ using content::Referrer; return self; } +- (WebDropData*)currentDropData { + return dropData_.get(); +} + - (void)setDragDelegate:(content::WebDragDestDelegate*)delegate { delegate_ = delegate; } @@ -37,7 +41,7 @@ using content::Referrer; // Call to set whether or not we should allow the drop. Takes effect the // next time |-draggingUpdated:| is called. - (void)setCurrentOperation:(NSDragOperation)operation { - current_operation_ = operation; + currentOperation_ = operation; } // Given a point in window coordinates and a view in that window, return a @@ -93,8 +97,9 @@ using content::Referrer; } // Fill out a WebDropData from pasteboard. - WebDropData data; - [self populateWebDropData:&data fromPasteboard:[info draggingPasteboard]]; + dropData_.reset(new WebDropData()); + [self populateWebDropData:dropData_.get() + fromPasteboard:[info draggingPasteboard]]; // Create the appropriate mouse locations for WebCore. The draggingLocation // is in window coordinates. Both need to be flipped. @@ -103,15 +108,15 @@ using content::Referrer; NSPoint screenPoint = [self flipWindowPointToScreen:windowPoint view:view]; NSDragOperation mask = [info draggingSourceOperationMask]; webContents_->GetRenderViewHost()->DragTargetDragEnter( - data, + *dropData_, gfx::Point(viewPoint.x, viewPoint.y), gfx::Point(screenPoint.x, screenPoint.y), static_cast<WebDragOperationsMask>(mask)); // We won't know the true operation (whether the drag is allowed) until we // hear back from the renderer. For now, be optimistic: - current_operation_ = NSDragOperationCopy; - return current_operation_; + currentOperation_ = NSDragOperationCopy; + return currentOperation_; } - (void)draggingExited:(id<NSDraggingInfo>)info { @@ -125,6 +130,7 @@ using content::Referrer; delegate_->OnDragLeave(); webContents_->GetRenderViewHost()->DragTargetDragLeave(); + dropData_.reset(); } - (NSDragOperation)draggingUpdated:(id<NSDraggingInfo>)info @@ -153,7 +159,7 @@ using content::Referrer; if (delegate_) delegate_->OnDragOver(); - return current_operation_; + return currentOperation_; } - (BOOL)performDragOperation:(id<NSDraggingInfo>)info @@ -162,6 +168,7 @@ using content::Referrer; [self draggingEntered:info view:view]; // Check if we only allow navigation and navigate to a url on the pasteboard. + BOOL result = YES; if ([self onlyAllowsNavigation]) { NSPasteboard* pboard = [info draggingPasteboard]; if ([pboard containsURLData]) { @@ -170,14 +177,14 @@ using content::Referrer; webContents_->OpenURL(OpenURLParams( url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_AUTO_BOOKMARK, false)); - return YES; + } else { + result = NO; } - return NO; + } else { + if (delegate_) + delegate_->OnDrop(); } - if (delegate_) - delegate_->OnDrop(); - currentRVH_ = NULL; // Create the appropriate mouse locations for WebCore. The draggingLocation @@ -189,7 +196,9 @@ using content::Referrer; gfx::Point(viewPoint.x, viewPoint.y), gfx::Point(screenPoint.x, screenPoint.y)); - return YES; + dropData_.reset(); + + return result; } // Given |data|, which should not be nil, fill it in using the contents of the |