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

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

Issue 12086095: Fixed drag and drop into and out of Browser Plugin. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Drag and drop enabled for linux only Created 7 years, 8 months 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 "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 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 // Flip |screenPoint|. 275 // Flip |screenPoint|.
276 NSRect screenFrame = [[[contentsView_ window] screen] frame]; 276 NSRect screenFrame = [[[contentsView_ window] screen] frame];
277 screenPoint.y = screenFrame.size.height - screenPoint.y; 277 screenPoint.y = screenFrame.size.height - screenPoint.y;
278 278
279 // If AppKit returns a copy and move operation, mask off the move bit 279 // If AppKit returns a copy and move operation, mask off the move bit
280 // because WebCore does not understand what it means to do both, which 280 // because WebCore does not understand what it means to do both, which
281 // results in an assertion failure/renderer crash. 281 // results in an assertion failure/renderer crash.
282 if (operation == (NSDragOperationMove | NSDragOperationCopy)) 282 if (operation == (NSDragOperationMove | NSDragOperationCopy))
283 operation &= ~NSDragOperationMove; 283 operation &= ~NSDragOperationMove;
284 284
285 rvh->DragSourceEndedAt(localPoint.x, localPoint.y, 285 contents_->DragSourceEndedAt(localPoint.x, localPoint.y, screenPoint.x,
286 screenPoint.x, screenPoint.y, 286 screenPoint.y, static_cast<WebKit::WebDragOperation>(operation));
287 static_cast<WebKit::WebDragOperation>(operation));
288 } 287 }
289 288
290 // Make sure the pasteboard owner isn't us. 289 // Make sure the pasteboard owner isn't us.
291 [pasteboard_ declareTypes:[NSArray array] owner:nil]; 290 [pasteboard_ declareTypes:[NSArray array] owner:nil];
292 } 291 }
293 292
294 - (void)moveDragTo:(NSPoint)screenPoint { 293 - (void)moveDragTo:(NSPoint)screenPoint {
295 if (!contents_) 294 if (!contents_)
296 return; 295 return;
297 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( 296 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>(
298 contents_->GetRenderViewHost()); 297 contents_->GetRenderViewHost());
299 if (rvh) { 298 if (rvh) {
300 // Convert |screenPoint| to view coordinates and flip it. 299 // Convert |screenPoint| to view coordinates and flip it.
301 NSPoint localPoint = NSMakePoint(0, 0); 300 NSPoint localPoint = NSMakePoint(0, 0);
302 if ([contentsView_ window]) 301 if ([contentsView_ window])
303 localPoint = [self convertScreenPoint:screenPoint]; 302 localPoint = [self convertScreenPoint:screenPoint];
304 NSRect viewFrame = [contentsView_ frame]; 303 NSRect viewFrame = [contentsView_ frame];
305 localPoint.y = viewFrame.size.height - localPoint.y; 304 localPoint.y = viewFrame.size.height - localPoint.y;
306 // Flip |screenPoint|. 305 // Flip |screenPoint|.
307 NSRect screenFrame = [[[contentsView_ window] screen] frame]; 306 NSRect screenFrame = [[[contentsView_ window] screen] frame];
308 screenPoint.y = screenFrame.size.height - screenPoint.y; 307 screenPoint.y = screenFrame.size.height - screenPoint.y;
309 308
310 rvh->DragSourceMovedTo(localPoint.x, localPoint.y, 309 contents_->DragSourceMovedTo(localPoint.x, localPoint.y,
311 screenPoint.x, screenPoint.y); 310 screenPoint.x, screenPoint.y);
312 } 311 }
313 } 312 }
314 313
315 - (NSString*)dragPromisedFileTo:(NSString*)path { 314 - (NSString*)dragPromisedFileTo:(NSString*)path {
316 // Be extra paranoid; avoid crashing. 315 // Be extra paranoid; avoid crashing.
317 if (!dropData_.get()) { 316 if (!dropData_.get()) {
318 NOTREACHED() << "No drag-and-drop data available for promised file."; 317 NOTREACHED() << "No drag-and-drop data available for promised file.";
319 return nil; 318 return nil;
320 } 319 }
321 320
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 - (NSImage*)dragImage { 461 - (NSImage*)dragImage {
463 if (dragImage_) 462 if (dragImage_)
464 return dragImage_; 463 return dragImage_;
465 464
466 // Default to returning a generic image. 465 // Default to returning a generic image.
467 return content::GetContentClient()->GetNativeImageNamed( 466 return content::GetContentClient()->GetNativeImageNamed(
468 IDR_DEFAULT_FAVICON).ToNSImage(); 467 IDR_DEFAULT_FAVICON).ToNSImage();
469 } 468 }
470 469
471 @end // @implementation WebDragSource (Private) 470 @end // @implementation WebDragSource (Private)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698