Index: ui/views/cocoa/bridged_content_view.mm |
diff --git a/ui/views/cocoa/bridged_content_view.mm b/ui/views/cocoa/bridged_content_view.mm |
index c269729cc2e73633e333f5df86dbb614518c3f0a..4478fd44005d1595ef830eb9ac58cb8ea54d7866 100644 |
--- a/ui/views/cocoa/bridged_content_view.mm |
+++ b/ui/views/cocoa/bridged_content_view.mm |
@@ -10,6 +10,7 @@ |
#include "base/strings/sys_string_conversions.h" |
#include "skia/ext/skia_utils_mac.h" |
#include "ui/base/cocoa/cocoa_base_utils.h" |
+#include "ui/base/dragdrop/os_exchange_data_provider_mac.h" |
#include "ui/base/ime/input_method.h" |
#include "ui/base/ime/text_input_client.h" |
#include "ui/compositor/canvas_painter.h" |
@@ -208,8 +209,10 @@ gfx::Rect GetFirstRectForRangeHelper(const ui::TextInputClient* client, |
@synthesize drawMenuBackgroundForBlur = drawMenuBackgroundForBlur_; |
@synthesize mouseDownCanMoveWindow = mouseDownCanMoveWindow_; |
-- (id)initWithView:(views::View*)viewToHost { |
+- (id)initWithView:(views::View*)viewToHost |
+ dragDropManager:(views::CocoaDragDropManager*)dragDropManager { |
DCHECK(viewToHost); |
+ DCHECK(dragDropManager); |
gfx::Rect bounds = viewToHost->bounds(); |
// To keep things simple, assume the origin is (0, 0) until there exists a use |
// case for something other than that. |
@@ -217,6 +220,7 @@ gfx::Rect GetFirstRectForRangeHelper(const ui::TextInputClient* client, |
NSRect initialFrame = NSMakeRect(0, 0, bounds.width(), bounds.height()); |
if ((self = [super initWithFrame:initialFrame])) { |
hostedView_ = viewToHost; |
+ drag_drop_manager_ = dragDropManager; |
// Apple's documentation says that NSTrackingActiveAlways is incompatible |
// with NSTrackingCursorUpdate, so use NSTrackingActiveInActiveApp. |
@@ -239,6 +243,10 @@ gfx::Rect GetFirstRectForRangeHelper(const ui::TextInputClient* client, |
// setting. |
[self updateFullKeyboardAccess]; |
} |
+ |
+ [self registerForDraggedTypes:ui::OSExchangeDataProviderMac:: |
+ SupportedPasteboardTypes()]; |
+ |
return self; |
} |
@@ -270,6 +278,22 @@ gfx::Rect GetFirstRectForRangeHelper(const ui::TextInputClient* client, |
hostedView_->GetWidget()->OnMouseEvent(&event); |
} |
+- (NSDragOperation)draggingEntered:(id<NSDraggingInfo>)sender { |
+ return drag_drop_manager_->DraggingOver(sender); |
+} |
+ |
+- (NSDragOperation)draggingUpdated:(id)sender { |
+ return drag_drop_manager_->DraggingOver(sender); |
+} |
+ |
+- (void)draggingEnded:(id)sender { |
+ drag_drop_manager_->EndDrag(); |
+} |
+ |
+- (BOOL)performDragOperation:(id<NSDraggingInfo>)sender { |
+ return drag_drop_manager_->OnDrop(sender) != NSDragOperationNone; |
+} |
+ |
- (void)updateTooltipIfRequiredAt:(const gfx::Point&)locationInContent { |
DCHECK(hostedView_); |
base::string16 newTooltipText; |