| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "chrome/browser/ui/cocoa/url_drop_target.h" | 5 #import "chrome/browser/ui/cocoa/url_drop_target.h" |
| 6 | 6 |
| 7 #include "chrome/browser/ui/cocoa/drag_util.h" | 7 #include "chrome/browser/ui/cocoa/drag_util.h" |
| 8 #import "third_party/mozilla/NSPasteboard+Utils.h" | 8 #import "third_party/mozilla/NSPasteboard+Utils.h" |
| 9 #include "ui/base/clipboard/clipboard_util_mac.h" |
| 9 #include "url/gurl.h" | 10 #include "url/gurl.h" |
| 10 | 11 |
| 11 namespace { | |
| 12 | |
| 13 // Mac WebKit uses this type, declared in | |
| 14 // WebKit/mac/History/WebURLsWithTitles.h. | |
| 15 NSString* const kCrWebURLsWithTitlesPboardType = | |
| 16 @"WebURLsWithTitlesPboardType"; | |
| 17 | |
| 18 } // namespace | |
| 19 | |
| 20 @interface URLDropTargetHandler(Private) | 12 @interface URLDropTargetHandler(Private) |
| 21 | 13 |
| 22 // Gets the appropriate drag operation given the |NSDraggingInfo|. | 14 // Gets the appropriate drag operation given the |NSDraggingInfo|. |
| 23 - (NSDragOperation)getDragOperation:(id<NSDraggingInfo>)sender; | 15 - (NSDragOperation)getDragOperation:(id<NSDraggingInfo>)sender; |
| 24 | 16 |
| 25 // Tell the window controller to hide the drop indicator. | 17 // Tell the window controller to hide the drop indicator. |
| 26 - (void)hideIndicator; | 18 - (void)hideIndicator; |
| 27 | 19 |
| 28 @end // @interface URLDropTargetHandler(Private) | 20 @end // @interface URLDropTargetHandler(Private) |
| 29 | 21 |
| 30 @implementation URLDropTargetHandler | 22 @implementation URLDropTargetHandler |
| 31 | 23 |
| 32 + (NSArray*)handledDragTypes { | 24 + (NSArray*)handledDragTypes { |
| 33 return [NSArray arrayWithObjects:kCrWebURLsWithTitlesPboardType, | 25 return @[ |
| 34 NSURLPboardType, | 26 ui::ClipboardUtil::UTIForWebURLsAndTitles(), NSURLPboardType, |
| 35 NSStringPboardType, | 27 NSStringPboardType, NSFilenamesPboardType |
| 36 NSFilenamesPboardType, | 28 ]; |
| 37 nil]; | |
| 38 } | 29 } |
| 39 | 30 |
| 40 - (id)initWithView:(NSView<URLDropTarget>*)view { | 31 - (id)initWithView:(NSView<URLDropTarget>*)view { |
| 41 if ((self = [super init])) { | 32 if ((self = [super init])) { |
| 42 view_ = view; | 33 view_ = view; |
| 43 [view_ registerForDraggedTypes:[URLDropTargetHandler handledDragTypes]]; | 34 [view_ registerForDraggedTypes:[URLDropTargetHandler handledDragTypes]]; |
| 44 } | 35 } |
| 45 return self; | 36 return self; |
| 46 } | 37 } |
| 47 | 38 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 | 116 |
| 126 // Only allow the copy operation. | 117 // Only allow the copy operation. |
| 127 return [sender draggingSourceOperationMask] & NSDragOperationCopy; | 118 return [sender draggingSourceOperationMask] & NSDragOperationCopy; |
| 128 } | 119 } |
| 129 | 120 |
| 130 - (void)hideIndicator { | 121 - (void)hideIndicator { |
| 131 [[view_ urlDropController] hideDropURLsIndicatorInView:view_]; | 122 [[view_ urlDropController] hideDropURLsIndicatorInView:view_]; |
| 132 } | 123 } |
| 133 | 124 |
| 134 @end // @implementation URLDropTargetHandler(Private) | 125 @end // @implementation URLDropTargetHandler(Private) |
| OLD | NEW |