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

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..af339ad7a0ff5761cb126c6a9f5a23239e95b9c2 100644
--- a/ui/views/cocoa/bridged_content_view.mm
+++ b/ui/views/cocoa/bridged_content_view.mm
@@ -10,6 +10,8 @@
#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/drag_drop_types.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"
@@ -23,9 +25,12 @@
#import "ui/gfx/path_mac.h"
#include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h"
#include "ui/strings/grit/ui_strings.h"
+#import "ui/views/cocoa/bridged_native_widget.h"
+#include "ui/views/cocoa/drag_drop_client_mac.h"
#include "ui/views/controls/menu/menu_config.h"
#include "ui/views/controls/menu/menu_controller.h"
#include "ui/views/view.h"
+#include "ui/views/widget/native_widget_mac.h"
#include "ui/views/widget/widget.h"
using views::MenuController;
@@ -191,6 +196,8 @@ gfx::Rect GetFirstRectForRangeHelper(const ui::TextInputClient* client,
// Notification handler invoked when the Full Keyboard Access mode is changed.
- (void)onFullKeyboardAccessModeChanged:(NSNotification*)notification;
+- (views::DragDropClientMac*)dragDropClient;
+
// Menu action handlers.
- (void)undo:(id)sender;
- (void)redo:(id)sender;
@@ -239,6 +246,10 @@ gfx::Rect GetFirstRectForRangeHelper(const ui::TextInputClient* client,
// setting.
[self updateFullKeyboardAccess];
}
+
+ [self registerForDraggedTypes:ui::OSExchangeDataProviderMac::
+ SupportedPasteboardTypes()];
+
return self;
}
@@ -270,6 +281,29 @@ gfx::Rect GetFirstRectForRangeHelper(const ui::TextInputClient* client,
hostedView_->GetWidget()->OnMouseEvent(&event);
}
+- (NSDragOperation)draggingEntered:(id<NSDraggingInfo>)sender {
+ return [self draggingUpdated:sender];
+}
+
+- (NSDragOperation)draggingUpdated:(id<NSDraggingInfo>)sender {
+ views::DragDropClientMac* client = [self dragDropClient];
+ return client ? client->DragUpdate(sender) : ui::DragDropTypes::DRAG_NONE;
+}
+
+- (void)draggingEnded:(id<NSDraggingInfo>)sender {
+ views::DragDropClientMac* client = [self dragDropClient];
+ if (client)
+ client->EndDrag();
+}
+
+- (BOOL)performDragOperation:(id<NSDraggingInfo>)sender {
+ views::DragDropClientMac* client = [self dragDropClient];
+ if (client)
+ return client->Drop(sender) != NSDragOperationNone;
+
+ return false;
tapted 2016/05/26 12:31:42 nit: false -> NO
spqchan 2016/05/27 23:25:48 Done.
+}
+
- (void)updateTooltipIfRequiredAt:(const gfx::Point&)locationInContent {
DCHECK(hostedView_);
base::string16 newTooltipText;
@@ -362,6 +396,12 @@ gfx::Rect GetFirstRectForRangeHelper(const ui::TextInputClient* client,
[self updateFullKeyboardAccess];
}
+- (views::DragDropClientMac*)dragDropClient {
+ views::BridgedNativeWidget* bridge =
+ views::NativeWidgetMac::GetBridgeForNativeWindow([self window]);
+ return bridge ? bridge->drag_drop_client() : nullptr;
+}
+
- (void)undo:(id)sender {
// This DCHECK is more strict than a similar check in handleAction:. It can be
// done here because the actors sending these actions should be calling

Powered by Google App Engine
This is Rietveld 408576698