| 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/file_path.h" | 10 #include "base/file_path.h" | 
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 128     dragOperationMask_ = dragOperationMask; | 128     dragOperationMask_ = dragOperationMask; | 
| 129 | 129 | 
| 130     fileExtension_ = nil; | 130     fileExtension_ = nil; | 
| 131 | 131 | 
| 132     [self fillPasteboard]; | 132     [self fillPasteboard]; | 
| 133   } | 133   } | 
| 134 | 134 | 
| 135   return self; | 135   return self; | 
| 136 } | 136 } | 
| 137 | 137 | 
|  | 138 - (void)clearWebContentsView { | 
|  | 139   contents_ = nil; | 
|  | 140   contentsView_ = nil; | 
|  | 141 } | 
|  | 142 | 
| 138 - (NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL)isLocal { | 143 - (NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL)isLocal { | 
| 139   return dragOperationMask_; | 144   return dragOperationMask_; | 
| 140 } | 145 } | 
| 141 | 146 | 
| 142 - (void)lazyWriteToPasteboard:(NSPasteboard*)pboard forType:(NSString*)type { | 147 - (void)lazyWriteToPasteboard:(NSPasteboard*)pboard forType:(NSString*)type { | 
| 143   // NSHTMLPboardType requires the character set to be declared. Otherwise, it | 148   // NSHTMLPboardType requires the character set to be declared. Otherwise, it | 
| 144   // assumes US-ASCII. Awesome. | 149   // assumes US-ASCII. Awesome. | 
| 145   const string16 kHtmlHeader = ASCIIToUTF16( | 150   const string16 kHtmlHeader = ASCIIToUTF16( | 
| 146       "<meta http-equiv=\"Content-Type\" content=\"text/html;charset=UTF-8\">"); | 151       "<meta http-equiv=\"Content-Type\" content=\"text/html;charset=UTF-8\">"); | 
| 147 | 152 | 
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 261                  at:position | 266                  at:position | 
| 262              offset:NSZeroSize | 267              offset:NSZeroSize | 
| 263               event:dragEvent | 268               event:dragEvent | 
| 264          pasteboard:pasteboard_ | 269          pasteboard:pasteboard_ | 
| 265              source:contentsView_ | 270              source:contentsView_ | 
| 266           slideBack:YES]; | 271           slideBack:YES]; | 
| 267 } | 272 } | 
| 268 | 273 | 
| 269 - (void)endDragAt:(NSPoint)screenPoint | 274 - (void)endDragAt:(NSPoint)screenPoint | 
| 270         operation:(NSDragOperation)operation { | 275         operation:(NSDragOperation)operation { | 
|  | 276   if (!contents_) | 
|  | 277     return; | 
| 271   contents_->SystemDragEnded(); | 278   contents_->SystemDragEnded(); | 
| 272 | 279 | 
| 273   RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | 280   RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | 
| 274       contents_->GetRenderViewHost()); | 281       contents_->GetRenderViewHost()); | 
| 275   if (rvh) { | 282   if (rvh) { | 
| 276     // Convert |screenPoint| to view coordinates and flip it. | 283     // Convert |screenPoint| to view coordinates and flip it. | 
| 277     NSPoint localPoint = NSMakePoint(0, 0); | 284     NSPoint localPoint = NSMakePoint(0, 0); | 
| 278     if ([contentsView_ window]) | 285     if ([contentsView_ window]) | 
| 279       localPoint = [self convertScreenPoint:screenPoint]; | 286       localPoint = [self convertScreenPoint:screenPoint]; | 
| 280     NSRect viewFrame = [contentsView_ frame]; | 287     NSRect viewFrame = [contentsView_ frame]; | 
| (...skipping 11 matching lines...) Expand all  Loading... | 
| 292     rvh->DragSourceEndedAt(localPoint.x, localPoint.y, | 299     rvh->DragSourceEndedAt(localPoint.x, localPoint.y, | 
| 293                            screenPoint.x, screenPoint.y, | 300                            screenPoint.x, screenPoint.y, | 
| 294                            static_cast<WebKit::WebDragOperation>(operation)); | 301                            static_cast<WebKit::WebDragOperation>(operation)); | 
| 295   } | 302   } | 
| 296 | 303 | 
| 297   // Make sure the pasteboard owner isn't us. | 304   // Make sure the pasteboard owner isn't us. | 
| 298   [pasteboard_ declareTypes:[NSArray array] owner:nil]; | 305   [pasteboard_ declareTypes:[NSArray array] owner:nil]; | 
| 299 } | 306 } | 
| 300 | 307 | 
| 301 - (void)moveDragTo:(NSPoint)screenPoint { | 308 - (void)moveDragTo:(NSPoint)screenPoint { | 
|  | 309   if (!contents_) | 
|  | 310     return; | 
| 302   RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | 311   RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | 
| 303       contents_->GetRenderViewHost()); | 312       contents_->GetRenderViewHost()); | 
| 304   if (rvh) { | 313   if (rvh) { | 
| 305     // Convert |screenPoint| to view coordinates and flip it. | 314     // Convert |screenPoint| to view coordinates and flip it. | 
| 306     NSPoint localPoint = NSMakePoint(0, 0); | 315     NSPoint localPoint = NSMakePoint(0, 0); | 
| 307     if ([contentsView_ window]) | 316     if ([contentsView_ window]) | 
| 308       localPoint = [self convertScreenPoint:screenPoint]; | 317       localPoint = [self convertScreenPoint:screenPoint]; | 
| 309     NSRect viewFrame = [contentsView_ frame]; | 318     NSRect viewFrame = [contentsView_ frame]; | 
| 310     localPoint.y = viewFrame.size.height - localPoint.y; | 319     localPoint.y = viewFrame.size.height - localPoint.y; | 
| 311     // Flip |screenPoint|. | 320     // Flip |screenPoint|. | 
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 455 - (NSImage*)dragImage { | 464 - (NSImage*)dragImage { | 
| 456   if (dragImage_) | 465   if (dragImage_) | 
| 457     return dragImage_; | 466     return dragImage_; | 
| 458 | 467 | 
| 459   // Default to returning a generic image. | 468   // Default to returning a generic image. | 
| 460   return content::GetContentClient()->GetNativeImageNamed( | 469   return content::GetContentClient()->GetNativeImageNamed( | 
| 461       IDR_DEFAULT_FAVICON).ToNSImage(); | 470       IDR_DEFAULT_FAVICON).ToNSImage(); | 
| 462 } | 471 } | 
| 463 | 472 | 
| 464 @end  // @implementation WebDragSource (Private) | 473 @end  // @implementation WebDragSource (Private) | 
| OLD | NEW | 
|---|