Chromium Code Reviews| 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 a59d4f0788461572994df001532e34bd5fbccace..8e1686ca2a326ae3d7acf901eba4393136506581 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" |
|
tapted
2016/05/31 11:49:58
nit: import
spqchan
2016/05/31 23:06:12
Done.
|
| #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; |
| @@ -225,6 +230,8 @@ base::string16 AttributedSubstringForRangeHelper( |
| // 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; |
| @@ -273,6 +280,10 @@ base::string16 AttributedSubstringForRangeHelper( |
| // setting. |
| [self updateFullKeyboardAccess]; |
| } |
| + |
| + [self registerForDraggedTypes:ui::OSExchangeDataProviderMac:: |
|
tapted
2016/05/31 11:49:57
nit: move this into the if {}
spqchan
2016/05/31 23:06:12
Done.
|
| + SupportedPasteboardTypes()]; |
| + |
| return self; |
| } |
| @@ -304,6 +315,23 @@ base::string16 AttributedSubstringForRangeHelper( |
| hostedView_->GetWidget()->OnMouseEvent(&event); |
| } |
| +- (NSDragOperation)draggingEntered:(id<NSDraggingInfo>)sender { |
|
tapted
2016/05/31 11:49:57
nit: these should move down after the other NSView
spqchan
2016/05/31 23:06:12
Done.
|
| + return [self draggingUpdated:sender]; |
| +} |
| + |
| +- (NSDragOperation)draggingUpdated:(id<NSDraggingInfo>)sender { |
| + views::DragDropClientMac* client = [self dragDropClient]; |
| + return client ? client->DragUpdate(sender) : ui::DragDropTypes::DRAG_NONE; |
| +} |
| + |
| +- (BOOL)performDragOperation:(id<NSDraggingInfo>)sender { |
| + views::DragDropClientMac* client = [self dragDropClient]; |
| + if (client) |
| + return client->Drop(sender) != NSDragOperationNone; |
| + |
| + return NO; |
|
tapted
2016/05/31 11:49:57
nit: we can do just
return client && client->Drop
spqchan
2016/05/31 23:06:12
Done.
|
| +} |
| + |
| - (void)updateTooltipIfRequiredAt:(const gfx::Point&)locationInContent { |
| DCHECK(hostedView_); |
| base::string16 newTooltipText; |
| @@ -396,6 +424,12 @@ base::string16 AttributedSubstringForRangeHelper( |
| [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 |
| @@ -1191,4 +1225,19 @@ base::string16 AttributedSubstringForRangeHelper( |
| return [hostedView_->GetNativeViewAccessible() accessibilityHitTest:point]; |
| } |
| +// NSDraggingSource protocol implementation |
|
tapted
2016/05/31 11:49:57
nit: move this up, to come after NSUserInterfaceVa
spqchan
2016/05/31 23:06:12
Done.
|
| + |
| +- (NSDragOperation)draggingSession:(NSDraggingSession*)session |
| + sourceOperationMaskForDraggingContext:(NSDraggingContext)context { |
| + return NSDragOperationEvery; |
| +} |
| + |
| +- (void)draggingSession:(NSDraggingSession*)session |
| + endedAtPoint:(NSPoint)screenPoint |
| + operation:(NSDragOperation)operation { |
| + views::DragDropClientMac* client = [self dragDropClient]; |
| + if (client) |
| + client->EndDrag(); |
| +} |
| + |
| @end |