diff options
author | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-01 16:21:50 +0000 |
---|---|---|
committer | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-01 16:21:50 +0000 |
commit | 7f90af2d38c31478321a2666f034ec285ad98c80 (patch) | |
tree | d5a59ac760e8acbe3a5919164a0fe82bd3045baa /chrome/browser/ui | |
parent | 0750fadef0df3cf0331c441a963e76f661c0cd37 (diff) | |
download | chromium_src-7f90af2d38c31478321a2666f034ec285ad98c80.zip chromium_src-7f90af2d38c31478321a2666f034ec285ad98c80.tar.gz chromium_src-7f90af2d38c31478321a2666f034ec285ad98c80.tar.bz2 |
Split Mac WebDropTarget into two, content and chrome.
BUG=95573
TEST=no visible change
Review URL: http://codereview.chromium.org/8430013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@108113 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui')
-rw-r--r-- | chrome/browser/ui/cocoa/tab_contents/web_drop_target.h | 13 | ||||
-rw-r--r-- | chrome/browser/ui/cocoa/tab_contents/web_drop_target.mm | 49 |
2 files changed, 25 insertions, 37 deletions
diff --git a/chrome/browser/ui/cocoa/tab_contents/web_drop_target.h b/chrome/browser/ui/cocoa/tab_contents/web_drop_target.h index 566a585..c7c5451 100644 --- a/chrome/browser/ui/cocoa/tab_contents/web_drop_target.h +++ b/chrome/browser/ui/cocoa/tab_contents/web_drop_target.h @@ -9,9 +9,12 @@ class GURL; class RenderViewHost; class TabContents; -class TabContentsWrapper; struct WebDropData; +namespace content { +class WebDragDestDelegate; +} + // A typedef for a RenderViewHost used for comparison purposes only. typedef RenderViewHost* RenderViewHostIdentifier; @@ -24,10 +27,8 @@ typedef RenderViewHost* RenderViewHostIdentifier; // Our associated TabContents. Weak reference. TabContents* tabContents_; - // The TabContentsWrapper for |tab_contents_|. - // Weak reference; may be NULL if the contents aren't contained in a wrapper - // (e.g. WebUI dialogs). - TabContentsWrapper* tab_; + // Delegate; weak. + content::WebDragDestDelegate* delegate_; // Updated asynchronously during a drag to tell us whether or not we should // allow the drop. @@ -43,6 +44,8 @@ typedef RenderViewHost* RenderViewHostIdentifier; // (if necessary). - (id)initWithTabContents:(TabContents*)contents; +- (void)setDragDelegate:(content::WebDragDestDelegate*)delegate; + // Sets the current operation negotiated by the source and destination, // which determines whether or not we should allow the drop. Takes effect the // next time |-draggingUpdated:| is called. diff --git a/chrome/browser/ui/cocoa/tab_contents/web_drop_target.mm b/chrome/browser/ui/cocoa/tab_contents/web_drop_target.mm index 13b1f57..fa5043ef 100644 --- a/chrome/browser/ui/cocoa/tab_contents/web_drop_target.mm +++ b/chrome/browser/ui/cocoa/tab_contents/web_drop_target.mm @@ -5,13 +5,9 @@ #import "chrome/browser/ui/cocoa/tab_contents/web_drop_target.h" #include "base/sys_string_conversions.h" -#include "chrome/browser/bookmarks/bookmark_node_data.h" -#include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" -#include "chrome/browser/ui/browser.h" -#include "chrome/browser/ui/browser_window.h" -#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "content/browser/renderer_host/render_view_host.h" #include "content/browser/tab_contents/tab_contents.h" +#include "content/browser/tab_contents/web_drag_dest_delegate.h" #import "third_party/mozilla/NSPasteboard+Utils.h" #import "ui/base/dragdrop/cocoa_dnd_util.h" #include "webkit/glue/webdropdata.h" @@ -31,6 +27,10 @@ using WebKit::WebDragOperationsMask; return self; } +- (void)setDragDelegate:(content::WebDragDestDelegate*)delegate { + delegate_ = delegate; +} + // Call to set whether or not we should allow the drop. Takes effect the // next time |-draggingUpdated:| is called. - (void)setCurrentOperation: (NSDragOperation)operation { @@ -84,15 +84,10 @@ using WebKit::WebDragOperationsMask; return NSDragOperationNone; } - if (!tab_) - tab_ = TabContentsWrapper::GetCurrentWrapperForContents(tabContents_); - - // If the tab is showing the bookmark manager, send BookmarkDrag events - BookmarkTabHelper::BookmarkDrag* dragDelegate = - tab_ ? tab_->bookmark_tab_helper()->GetBookmarkDragDelegate() : NULL; - BookmarkNodeData dragData; - if(dragDelegate && dragData.ReadFromDragClipboard()) - dragDelegate->OnDragEnter(dragData); + if (delegate_) { + delegate_->DragInitialize(tabContents_); + delegate_->OnDragEnter(); + } // Fill out a WebDropData from pasteboard. WebDropData data; @@ -122,6 +117,9 @@ using WebKit::WebDragOperationsMask; // Nothing to do in the interstitial case. + if (delegate_) + delegate_->OnDragLeave(); + tabContents_->render_view_host()->DragTargetDragLeave(); } @@ -148,12 +146,9 @@ using WebKit::WebDragOperationsMask; gfx::Point(screenPoint.x, screenPoint.y), static_cast<WebDragOperationsMask>(mask)); - // If the tab is showing the bookmark manager, send BookmarkDrag events - BookmarkTabHelper::BookmarkDrag* dragDelegate = - tab_ ? tab_->bookmark_tab_helper()->GetBookmarkDragDelegate() : NULL; - BookmarkNodeData dragData; - if(dragDelegate && dragData.ReadFromDragClipboard()) - dragDelegate->OnDragOver(dragData); + if (delegate_) + delegate_->OnDragOver(); + return current_operation_; } @@ -175,12 +170,8 @@ using WebKit::WebDragOperationsMask; return NO; } - // If the tab is showing the bookmark manager, send BookmarkDrag events - BookmarkTabHelper::BookmarkDrag* dragDelegate = - tab_ ? tab_->bookmark_tab_helper()->GetBookmarkDragDelegate() : NULL; - BookmarkNodeData dragData; - if(dragDelegate && dragData.ReadFromDragClipboard()) - dragDelegate->OnDrop(dragData); + if (delegate_) + delegate_->OnDrop(); currentRVH_ = NULL; @@ -193,12 +184,6 @@ using WebKit::WebDragOperationsMask; gfx::Point(viewPoint.x, viewPoint.y), gfx::Point(screenPoint.x, screenPoint.y)); - // Focus the target browser. - Browser* browser = Browser::GetBrowserForController( - &tabContents_->controller(), NULL); - if (browser) - browser->window()->Show(); - return YES; } |