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

Side by Side Diff: content/browser/web_contents/web_contents_view_mac.mm

Issue 2509933002: Drag-and-drop: Target drag messages (the sequel). (Closed)
Patch Set: Addressed additional comments by avi@, dcheng@. Created 4 years, 1 month 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 unified diff | Download patch
OLDNEW
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 <Carbon/Carbon.h> 5 #import <Carbon/Carbon.h>
6 6
7 #import "content/browser/web_contents/web_contents_view_mac.h" 7 #import "content/browser/web_contents/web_contents_view_mac.h"
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 STATIC_ASSERT_ENUM(NSDragOperationMove, blink::WebDragOperationMove); 58 STATIC_ASSERT_ENUM(NSDragOperationMove, blink::WebDragOperationMove);
59 STATIC_ASSERT_ENUM(NSDragOperationDelete, blink::WebDragOperationDelete); 59 STATIC_ASSERT_ENUM(NSDragOperationDelete, blink::WebDragOperationDelete);
60 STATIC_ASSERT_ENUM(NSDragOperationEvery, blink::WebDragOperationEvery); 60 STATIC_ASSERT_ENUM(NSDragOperationEvery, blink::WebDragOperationEvery);
61 61
62 @interface WebContentsViewCocoa (Private) 62 @interface WebContentsViewCocoa (Private)
63 - (id)initWithWebContentsViewMac:(WebContentsViewMac*)w; 63 - (id)initWithWebContentsViewMac:(WebContentsViewMac*)w;
64 - (void)registerDragTypes; 64 - (void)registerDragTypes;
65 - (void)setCurrentDragOperation:(NSDragOperation)operation; 65 - (void)setCurrentDragOperation:(NSDragOperation)operation;
66 - (DropData*)dropData; 66 - (DropData*)dropData;
67 - (void)startDragWithDropData:(const DropData&)dropData 67 - (void)startDragWithDropData:(const DropData&)dropData
68 sourceRWH:(content::RenderWidgetHostImpl*)sourceRWH
68 dragOperationMask:(NSDragOperation)operationMask 69 dragOperationMask:(NSDragOperation)operationMask
69 image:(NSImage*)image 70 image:(NSImage*)image
70 offset:(NSPoint)offset; 71 offset:(NSPoint)offset;
71 - (void)cancelDeferredClose; 72 - (void)cancelDeferredClose;
72 - (void)clearWebContentsView; 73 - (void)clearWebContentsView;
73 - (void)closeTabAfterEvent; 74 - (void)closeTabAfterEvent;
74 - (void)updateWebContentsVisibility; 75 - (void)updateWebContentsVisibility;
75 - (void)viewDidBecomeFirstResponder:(NSNotification*)notification; 76 - (void)viewDidBecomeFirstResponder:(NSNotification*)notification;
76 - (content::WebContentsImpl*)webContents; 77 - (content::WebContentsImpl*)webContents;
77 @end 78 @end
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 base::mac::ScopedSendingEvent sending_event_scoper; 185 base::mac::ScopedSendingEvent sending_event_scoper;
185 186
186 // The drag invokes a nested event loop, arrange to continue 187 // The drag invokes a nested event loop, arrange to continue
187 // processing events. 188 // processing events.
188 base::MessageLoop::ScopedNestableTaskAllower allow( 189 base::MessageLoop::ScopedNestableTaskAllower allow(
189 base::MessageLoop::current()); 190 base::MessageLoop::current());
190 NSDragOperation mask = static_cast<NSDragOperation>(allowed_operations); 191 NSDragOperation mask = static_cast<NSDragOperation>(allowed_operations);
191 NSPoint offset = NSPointFromCGPoint( 192 NSPoint offset = NSPointFromCGPoint(
192 gfx::PointAtOffsetFromOrigin(image_offset).ToCGPoint()); 193 gfx::PointAtOffsetFromOrigin(image_offset).ToCGPoint());
193 [cocoa_view_ startDragWithDropData:drop_data 194 [cocoa_view_ startDragWithDropData:drop_data
195 sourceRWH:source_rwh
194 dragOperationMask:mask 196 dragOperationMask:mask
195 image:gfx::NSImageFromImageSkia(image) 197 image:gfx::NSImageFromImageSkia(image)
196 offset:offset]; 198 offset:offset];
197 } 199 }
198 200
199 void WebContentsViewMac::SizeContents(const gfx::Size& size) { 201 void WebContentsViewMac::SizeContents(const gfx::Size& size) {
200 // TODO(brettw | japhet) This is a hack and should be removed. 202 // TODO(brettw | japhet) This is a hack and should be removed.
201 // See web_contents_view.h. 203 // See web_contents_view.h.
202 // Note(erikchen): This method has /never/ worked correctly. I've removed the 204 // Note(erikchen): This method has /never/ worked correctly. I've removed the
203 // previous implementation. 205 // previous implementation.
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 DCHECK(view); 536 DCHECK(view);
535 [view->cocoa_view() setOpaque:opaque]; 537 [view->cocoa_view() setOpaque:opaque];
536 } 538 }
537 539
538 - (void)pasteboard:(NSPasteboard*)sender provideDataForType:(NSString*)type { 540 - (void)pasteboard:(NSPasteboard*)sender provideDataForType:(NSString*)type {
539 [dragSource_ lazyWriteToPasteboard:sender 541 [dragSource_ lazyWriteToPasteboard:sender
540 forType:type]; 542 forType:type];
541 } 543 }
542 544
543 - (void)startDragWithDropData:(const DropData&)dropData 545 - (void)startDragWithDropData:(const DropData&)dropData
546 sourceRWH:(content::RenderWidgetHostImpl*)sourceRWH
544 dragOperationMask:(NSDragOperation)operationMask 547 dragOperationMask:(NSDragOperation)operationMask
545 image:(NSImage*)image 548 image:(NSImage*)image
546 offset:(NSPoint)offset { 549 offset:(NSPoint)offset {
547 if (![self webContents]) 550 if (![self webContents])
548 return; 551 return;
549 dragSource_.reset([[WebDragSource alloc] 552 dragSource_.reset([[WebDragSource alloc]
550 initWithContents:[self webContents] 553 initWithContents:[self webContents]
551 view:self 554 view:self
552 dropData:&dropData 555 dropData:&dropData
553 image:image 556 sourceRWH:sourceRWH
554 offset:offset 557 image:image
555 pasteboard:[NSPasteboard pasteboardWithName:NSDragPboard] 558 offset:offset
556 dragOperationMask:operationMask]); 559 pasteboard:[NSPasteboard pasteboardWithName:NSDragPboard]
560 dragOperationMask:operationMask]);
557 [dragSource_ startDrag]; 561 [dragSource_ startDrag];
558 } 562 }
559 563
560 // NSDraggingSource methods 564 // NSDraggingSource methods
561 565
562 - (NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL)isLocal { 566 - (NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL)isLocal {
563 if (dragSource_) 567 if (dragSource_)
564 return [dragSource_ draggingSourceOperationMaskForLocal:isLocal]; 568 return [dragSource_ draggingSourceOperationMaskForLocal:isLocal];
565 // No web drag source - this is the case for dragging a file from the 569 // No web drag source - this is the case for dragging a file from the
566 // downloads manager. Default to copy operation. Note: It is desirable to 570 // downloads manager. Default to copy operation. Note: It is desirable to
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
719 723
720 - (void)viewDidHide { 724 - (void)viewDidHide {
721 [self updateWebContentsVisibility]; 725 [self updateWebContentsVisibility];
722 } 726 }
723 727
724 - (void)viewDidUnhide { 728 - (void)viewDidUnhide {
725 [self updateWebContentsVisibility]; 729 [self updateWebContentsVisibility];
726 } 730 }
727 731
728 @end 732 @end
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_view_guest.cc ('k') | content/browser/web_contents/web_drag_dest_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698