| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/web_drag_source.h" | 5 #import "chrome/browser/ui/cocoa/web_drag_source.h" |
| 6 | 6 |
| 7 #include "app/mac/nsimage_cache.h" | 7 #include "app/mac/nsimage_cache.h" |
| 8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/sys_string_conversions.h" | 10 #include "base/sys_string_conversions.h" |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 slideBack:YES]; | 250 slideBack:YES]; |
| 251 } | 251 } |
| 252 | 252 |
| 253 - (void)endDragAt:(NSPoint)screenPoint | 253 - (void)endDragAt:(NSPoint)screenPoint |
| 254 operation:(NSDragOperation)operation { | 254 operation:(NSDragOperation)operation { |
| 255 RenderViewHost* rvh = [contentsView_ tabContents]->render_view_host(); | 255 RenderViewHost* rvh = [contentsView_ tabContents]->render_view_host(); |
| 256 if (rvh) { | 256 if (rvh) { |
| 257 rvh->DragSourceSystemDragEnded(); | 257 rvh->DragSourceSystemDragEnded(); |
| 258 | 258 |
| 259 // Convert |screenPoint| to view coordinates and flip it. | 259 // Convert |screenPoint| to view coordinates and flip it. |
| 260 NSPoint localPoint = [self convertScreenPoint:screenPoint]; | 260 NSPoint localPoint = NSMakePoint(0, 0); |
| 261 if ([contentsView_ window]) |
| 262 localPoint = [self convertScreenPoint:screenPoint]; |
| 261 NSRect viewFrame = [contentsView_ frame]; | 263 NSRect viewFrame = [contentsView_ frame]; |
| 262 localPoint.y = viewFrame.size.height - localPoint.y; | 264 localPoint.y = viewFrame.size.height - localPoint.y; |
| 263 // Flip |screenPoint|. | 265 // Flip |screenPoint|. |
| 264 NSRect screenFrame = [[[contentsView_ window] screen] frame]; | 266 NSRect screenFrame = [[[contentsView_ window] screen] frame]; |
| 265 screenPoint.y = screenFrame.size.height - screenPoint.y; | 267 screenPoint.y = screenFrame.size.height - screenPoint.y; |
| 266 | 268 |
| 267 rvh->DragSourceEndedAt(localPoint.x, localPoint.y, | 269 rvh->DragSourceEndedAt(localPoint.x, localPoint.y, |
| 268 screenPoint.x, screenPoint.y, | 270 screenPoint.x, screenPoint.y, |
| 269 static_cast<WebKit::WebDragOperation>(operation)); | 271 static_cast<WebKit::WebDragOperation>(operation)); |
| 270 } | 272 } |
| 271 | 273 |
| 272 // Make sure the pasteboard owner isn't us. | 274 // Make sure the pasteboard owner isn't us. |
| 273 [pasteboard_ declareTypes:[NSArray array] owner:nil]; | 275 [pasteboard_ declareTypes:[NSArray array] owner:nil]; |
| 274 } | 276 } |
| 275 | 277 |
| 276 - (void)moveDragTo:(NSPoint)screenPoint { | 278 - (void)moveDragTo:(NSPoint)screenPoint { |
| 277 RenderViewHost* rvh = [contentsView_ tabContents]->render_view_host(); | 279 RenderViewHost* rvh = [contentsView_ tabContents]->render_view_host(); |
| 278 if (rvh) { | 280 if (rvh) { |
| 279 // Convert |screenPoint| to view coordinates and flip it. | 281 // Convert |screenPoint| to view coordinates and flip it. |
| 280 NSPoint localPoint = [self convertScreenPoint:screenPoint]; | 282 NSPoint localPoint = NSMakePoint(0, 0); |
| 283 if ([contentsView_ window]) |
| 284 localPoint = [self convertScreenPoint:screenPoint]; |
| 281 NSRect viewFrame = [contentsView_ frame]; | 285 NSRect viewFrame = [contentsView_ frame]; |
| 282 localPoint.y = viewFrame.size.height - localPoint.y; | 286 localPoint.y = viewFrame.size.height - localPoint.y; |
| 283 // Flip |screenPoint|. | 287 // Flip |screenPoint|. |
| 284 NSRect screenFrame = [[[contentsView_ window] screen] frame]; | 288 NSRect screenFrame = [[[contentsView_ window] screen] frame]; |
| 285 screenPoint.y = screenFrame.size.height - screenPoint.y; | 289 screenPoint.y = screenFrame.size.height - screenPoint.y; |
| 286 | 290 |
| 287 rvh->DragSourceMovedTo(localPoint.x, localPoint.y, | 291 rvh->DragSourceMovedTo(localPoint.x, localPoint.y, |
| 288 screenPoint.x, screenPoint.y); | 292 screenPoint.x, screenPoint.y); |
| 289 } | 293 } |
| 290 } | 294 } |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 | 407 |
| 404 - (NSImage*)dragImage { | 408 - (NSImage*)dragImage { |
| 405 if (dragImage_) | 409 if (dragImage_) |
| 406 return dragImage_; | 410 return dragImage_; |
| 407 | 411 |
| 408 // Default to returning a generic image. | 412 // Default to returning a generic image. |
| 409 return app::mac::GetCachedImageWithName(@"nav.pdf"); | 413 return app::mac::GetCachedImageWithName(@"nav.pdf"); |
| 410 } | 414 } |
| 411 | 415 |
| 412 @end // @implementation WebDragSource (Private) | 416 @end // @implementation WebDragSource (Private) |
| OLD | NEW |