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..b06aa5c0568310cab4706341bee8fce4d69eab2c 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" |
| +#import "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; |
| @@ -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; |
| @@ -272,6 +279,8 @@ base::string16 AttributedSubstringForRangeHelper( |
| // Initialize the focus manager with the correct keyboard accessibility |
| // setting. |
| [self updateFullKeyboardAccess]; |
| + [self registerForDraggedTypes:ui::OSExchangeDataProviderMac:: |
| + SupportedPasteboardTypes()]; |
| } |
| return self; |
| } |
| @@ -396,6 +405,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 |
| @@ -585,6 +600,22 @@ base::string16 AttributedSubstringForRangeHelper( |
| return YES; |
| } |
| +// NSDraggingDestination protocol overrides: |
|
tapted
2016/06/01 01:57:01
nit: full stop instead of colon
spqchan
2016/06/01 19:09:28
Done.
|
| + |
| +- (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; |
| +} |
| + |
| +- (BOOL)performDragOperation:(id<NSDraggingInfo>)sender { |
| + views::DragDropClientMac* client = [self dragDropClient]; |
| + return client && client->Drop(sender) != NSDragOperationNone; |
| +} |
| + |
| - (NSTextInputContext*)inputContext { |
| // If the textInputClient_ does not exist, return nil since this view does not |
| // conform to NSTextInputClient protocol. |
| @@ -1177,6 +1208,21 @@ base::string16 AttributedSubstringForRangeHelper( |
| return NO; |
| } |
| +// NSDraggingSource protocol implementation |
|
tapted
2016/06/01 01:57:00
nit: full stop at end
spqchan
2016/06/01 19:09:28
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(); |
| +} |
| + |
| // NSAccessibility informal protocol implementation. |
| - (id)accessibilityAttributeValue:(NSString*)attribute { |