| 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 <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 #include "content/browser/download/drag_download_util.h" | 23 #include "content/browser/download/drag_download_util.h" |
| 24 #include "content/browser/renderer_host/render_view_host_impl.h" | 24 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 25 #include "content/browser/web_contents/web_contents_impl.h" | 25 #include "content/browser/web_contents/web_contents_impl.h" |
| 26 #include "content/public/browser/content_browser_client.h" | 26 #include "content/public/browser/content_browser_client.h" |
| 27 #include "content/public/common/content_client.h" | 27 #include "content/public/common/content_client.h" |
| 28 #include "content/public/common/drop_data.h" | 28 #include "content/public/common/drop_data.h" |
| 29 #include "net/base/escape.h" | 29 #include "net/base/escape.h" |
| 30 #include "net/base/filename_util.h" | 30 #include "net/base/filename_util.h" |
| 31 #include "net/base/mime_util.h" | 31 #include "net/base/mime_util.h" |
| 32 #include "ui/base/clipboard/custom_data_helper.h" | 32 #include "ui/base/clipboard/custom_data_helper.h" |
| 33 #include "ui/base/cocoa/cocoa_base_utils.h" |
| 33 #include "ui/base/dragdrop/cocoa_dnd_util.h" | 34 #include "ui/base/dragdrop/cocoa_dnd_util.h" |
| 34 #include "ui/gfx/image/image.h" | 35 #include "ui/gfx/image/image.h" |
| 35 #include "ui/resources/grit/ui_resources.h" | 36 #include "ui/resources/grit/ui_resources.h" |
| 36 #include "url/url_constants.h" | 37 #include "url/url_constants.h" |
| 37 | 38 |
| 38 using base::SysNSStringToUTF8; | 39 using base::SysNSStringToUTF8; |
| 39 using base::SysUTF8ToNSString; | 40 using base::SysUTF8ToNSString; |
| 40 using base::SysUTF16ToNSString; | 41 using base::SysUTF16ToNSString; |
| 41 using content::BrowserThread; | 42 using content::BrowserThread; |
| 42 using content::DragDownloadFile; | 43 using content::DragDownloadFile; |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 | 216 |
| 216 // Oops! | 217 // Oops! |
| 217 } else { | 218 } else { |
| 218 // Unknown drag pasteboard type. | 219 // Unknown drag pasteboard type. |
| 219 NOTREACHED(); | 220 NOTREACHED(); |
| 220 } | 221 } |
| 221 } | 222 } |
| 222 | 223 |
| 223 - (NSPoint)convertScreenPoint:(NSPoint)screenPoint { | 224 - (NSPoint)convertScreenPoint:(NSPoint)screenPoint { |
| 224 DCHECK([contentsView_ window]); | 225 DCHECK([contentsView_ window]); |
| 225 NSPoint basePoint = [[contentsView_ window] convertScreenToBase:screenPoint]; | 226 NSPoint basePoint = |
| 227 ui::ConvertPointFromScreenToWindow([contentsView_ window], screenPoint); |
| 226 return [contentsView_ convertPoint:basePoint fromView:nil]; | 228 return [contentsView_ convertPoint:basePoint fromView:nil]; |
| 227 } | 229 } |
| 228 | 230 |
| 229 - (void)startDrag { | 231 - (void)startDrag { |
| 230 if (!contentsView_) | 232 if (!contentsView_) |
| 231 return; | 233 return; |
| 232 | 234 |
| 233 NSEvent* currentEvent = [NSApp currentEvent]; | 235 NSEvent* currentEvent = [NSApp currentEvent]; |
| 234 | 236 |
| 235 // Synthesize an event for dragging, since we can't be sure that | 237 // Synthesize an event for dragging, since we can't be sure that |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 - (NSImage*)dragImage { | 464 - (NSImage*)dragImage { |
| 463 if (dragImage_) | 465 if (dragImage_) |
| 464 return dragImage_; | 466 return dragImage_; |
| 465 | 467 |
| 466 // Default to returning a generic image. | 468 // Default to returning a generic image. |
| 467 return content::GetContentClient()->GetNativeImageNamed( | 469 return content::GetContentClient()->GetNativeImageNamed( |
| 468 IDR_DEFAULT_FAVICON).ToNSImage(); | 470 IDR_DEFAULT_FAVICON).ToNSImage(); |
| 469 } | 471 } |
| 470 | 472 |
| 471 @end // @implementation WebDragSource (Private) | 473 @end // @implementation WebDragSource (Private) |
| OLD | NEW |