Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(991)

Unified Diff: ui/views/cocoa/bridged_content_view.mm

Issue 1964283002: MacViews: Implemented Drag & Drop (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;

Powered by Google App Engine
This is Rietveld 408576698