| 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 "content/browser/web_contents/web_drag_source_mac.h" | 5 #import "content/browser/web_contents/web_drag_source_mac.h" |
| 6 | 6 |
| 7 #include <sys/param.h> | 7 #include <sys/param.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 // Flip |screenPoint|. | 276 // Flip |screenPoint|. |
| 277 NSRect screenFrame = [[[contentsView_ window] screen] frame]; | 277 NSRect screenFrame = [[[contentsView_ window] screen] frame]; |
| 278 screenPoint.y = screenFrame.size.height - screenPoint.y; | 278 screenPoint.y = screenFrame.size.height - screenPoint.y; |
| 279 | 279 |
| 280 // If AppKit returns a copy and move operation, mask off the move bit | 280 // If AppKit returns a copy and move operation, mask off the move bit |
| 281 // because WebCore does not understand what it means to do both, which | 281 // because WebCore does not understand what it means to do both, which |
| 282 // results in an assertion failure/renderer crash. | 282 // results in an assertion failure/renderer crash. |
| 283 if (operation == (NSDragOperationMove | NSDragOperationCopy)) | 283 if (operation == (NSDragOperationMove | NSDragOperationCopy)) |
| 284 operation &= ~NSDragOperationMove; | 284 operation &= ~NSDragOperationMove; |
| 285 | 285 |
| 286 rvh->DragSourceEndedAt(localPoint.x, localPoint.y, | 286 contents_->DragSourceEndedAt(localPoint.x, localPoint.y, screenPoint.x, |
| 287 screenPoint.x, screenPoint.y, | 287 screenPoint.y, static_cast<WebKit::WebDragOperation>(operation)); |
| 288 static_cast<WebKit::WebDragOperation>(operation)); | |
| 289 } | 288 } |
| 290 | 289 |
| 291 // Make sure the pasteboard owner isn't us. | 290 // Make sure the pasteboard owner isn't us. |
| 292 [pasteboard_ declareTypes:[NSArray array] owner:nil]; | 291 [pasteboard_ declareTypes:[NSArray array] owner:nil]; |
| 293 } | 292 } |
| 294 | 293 |
| 295 - (void)moveDragTo:(NSPoint)screenPoint { | 294 - (void)moveDragTo:(NSPoint)screenPoint { |
| 296 if (!contents_) | 295 if (!contents_) |
| 297 return; | 296 return; |
| 298 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | 297 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( |
| 299 contents_->GetRenderViewHost()); | 298 contents_->GetRenderViewHost()); |
| 300 if (rvh) { | 299 if (rvh) { |
| 301 // Convert |screenPoint| to view coordinates and flip it. | 300 // Convert |screenPoint| to view coordinates and flip it. |
| 302 NSPoint localPoint = NSMakePoint(0, 0); | 301 NSPoint localPoint = NSMakePoint(0, 0); |
| 303 if ([contentsView_ window]) | 302 if ([contentsView_ window]) |
| 304 localPoint = [self convertScreenPoint:screenPoint]; | 303 localPoint = [self convertScreenPoint:screenPoint]; |
| 305 NSRect viewFrame = [contentsView_ frame]; | 304 NSRect viewFrame = [contentsView_ frame]; |
| 306 localPoint.y = viewFrame.size.height - localPoint.y; | 305 localPoint.y = viewFrame.size.height - localPoint.y; |
| 307 // Flip |screenPoint|. | 306 // Flip |screenPoint|. |
| 308 NSRect screenFrame = [[[contentsView_ window] screen] frame]; | 307 NSRect screenFrame = [[[contentsView_ window] screen] frame]; |
| 309 screenPoint.y = screenFrame.size.height - screenPoint.y; | 308 screenPoint.y = screenFrame.size.height - screenPoint.y; |
| 310 | 309 |
| 311 rvh->DragSourceMovedTo(localPoint.x, localPoint.y, | 310 contents_->DragSourceMovedTo(localPoint.x, localPoint.y, |
| 312 screenPoint.x, screenPoint.y); | 311 screenPoint.x, screenPoint.y); |
| 313 } | 312 } |
| 314 } | 313 } |
| 315 | 314 |
| 316 - (NSString*)dragPromisedFileTo:(NSString*)path { | 315 - (NSString*)dragPromisedFileTo:(NSString*)path { |
| 317 // Be extra paranoid; avoid crashing. | 316 // Be extra paranoid; avoid crashing. |
| 318 if (!dropData_) { | 317 if (!dropData_) { |
| 319 NOTREACHED() << "No drag-and-drop data available for promised file."; | 318 NOTREACHED() << "No drag-and-drop data available for promised file."; |
| 320 return nil; | 319 return nil; |
| 321 } | 320 } |
| 322 | 321 |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 469 - (NSImage*)dragImage { | 468 - (NSImage*)dragImage { |
| 470 if (dragImage_) | 469 if (dragImage_) |
| 471 return dragImage_; | 470 return dragImage_; |
| 472 | 471 |
| 473 // Default to returning a generic image. | 472 // Default to returning a generic image. |
| 474 return content::GetContentClient()->GetNativeImageNamed( | 473 return content::GetContentClient()->GetNativeImageNamed( |
| 475 IDR_DEFAULT_FAVICON).ToNSImage(); | 474 IDR_DEFAULT_FAVICON).ToNSImage(); |
| 476 } | 475 } |
| 477 | 476 |
| 478 @end // @implementation WebDragSource (Private) | 477 @end // @implementation WebDragSource (Private) |
| OLD | NEW |