| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/tab_contents/web_drop_target.h" | 5 #import "content/browser/tab_contents/web_drag_dest_mac.h" |
| 6 | 6 |
| 7 #include "base/sys_string_conversions.h" | 7 #include "base/sys_string_conversions.h" |
| 8 #include "content/browser/renderer_host/render_view_host.h" | 8 #include "content/browser/renderer_host/render_view_host.h" |
| 9 #include "content/browser/tab_contents/tab_contents.h" | 9 #include "content/browser/tab_contents/tab_contents.h" |
| 10 #include "content/browser/tab_contents/web_drag_dest_delegate.h" | 10 #include "content/browser/tab_contents/web_drag_dest_delegate.h" |
| 11 #import "third_party/mozilla/NSPasteboard+Utils.h" | 11 #import "third_party/mozilla/NSPasteboard+Utils.h" |
| 12 #import "ui/base/dragdrop/cocoa_dnd_util.h" | 12 #import "ui/base/dragdrop/cocoa_dnd_util.h" |
| 13 #include "webkit/glue/webdropdata.h" | 13 #include "webkit/glue/webdropdata.h" |
| 14 #include "webkit/glue/window_open_disposition.h" | 14 #include "webkit/glue/window_open_disposition.h" |
| 15 | 15 |
| 16 using WebKit::WebDragOperationsMask; | 16 using WebKit::WebDragOperationsMask; |
| 17 | 17 |
| 18 @implementation WebDropTarget | 18 @implementation WebDragDest |
| 19 | 19 |
| 20 // |contents| is the TabContents representing this tab, used to communicate | 20 // |contents| is the TabContents representing this tab, used to communicate |
| 21 // drag&drop messages to WebCore and handle navigation on a successful drop | 21 // drag&drop messages to WebCore and handle navigation on a successful drop |
| 22 // (if necessary). | 22 // (if necessary). |
| 23 - (id)initWithTabContents:(TabContents*)contents { | 23 - (id)initWithTabContents:(TabContents*)contents { |
| 24 if ((self = [super init])) { | 24 if ((self = [super init])) { |
| 25 tabContents_ = contents; | 25 tabContents_ = contents; |
| 26 } | 26 } |
| 27 return self; | 27 return self; |
| 28 } | 28 } |
| 29 | 29 |
| 30 - (void)setDragDelegate:(content::WebDragDestDelegate*)delegate { | 30 - (void)setDragDelegate:(content::WebDragDestDelegate*)delegate { |
| 31 delegate_ = delegate; | 31 delegate_ = delegate; |
| 32 } | 32 } |
| 33 | 33 |
| 34 // Call to set whether or not we should allow the drop. Takes effect the | 34 // Call to set whether or not we should allow the drop. Takes effect the |
| 35 // next time |-draggingUpdated:| is called. | 35 // next time |-draggingUpdated:| is called. |
| 36 - (void)setCurrentOperation: (NSDragOperation)operation { | 36 - (void)setCurrentOperation:(NSDragOperation)operation { |
| 37 current_operation_ = operation; | 37 current_operation_ = operation; |
| 38 } | 38 } |
| 39 | 39 |
| 40 // Given a point in window coordinates and a view in that window, return a | 40 // Given a point in window coordinates and a view in that window, return a |
| 41 // flipped point in the coordinate system of |view|. | 41 // flipped point in the coordinate system of |view|. |
| 42 - (NSPoint)flipWindowPointToView:(const NSPoint&)windowPoint | 42 - (NSPoint)flipWindowPointToView:(const NSPoint&)windowPoint |
| 43 view:(NSView*)view { | 43 view:(NSView*)view { |
| 44 DCHECK(view); | 44 DCHECK(view); |
| 45 NSPoint viewPoint = [view convertPoint:windowPoint fromView:nil]; | 45 NSPoint viewPoint = [view convertPoint:windowPoint fromView:nil]; |
| 46 NSRect viewFrame = [view frame]; | 46 NSRect viewFrame = [view frame]; |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 if (exists && !isDir) | 229 if (exists && !isDir) |
| 230 data->filenames.push_back(base::SysNSStringToUTF16(filename)); | 230 data->filenames.push_back(base::SysNSStringToUTF16(filename)); |
| 231 } | 231 } |
| 232 } | 232 } |
| 233 } | 233 } |
| 234 | 234 |
| 235 // TODO(pinkerton): Get file contents. http://crbug.com/34661 | 235 // TODO(pinkerton): Get file contents. http://crbug.com/34661 |
| 236 } | 236 } |
| 237 | 237 |
| 238 @end | 238 @end |
| OLD | NEW |