| 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 // kPasteboardTypeFileURLPromise is PasteboardCopyPasteLocation, which takes | 97 // kPasteboardTypeFileURLPromise is PasteboardCopyPasteLocation, which takes |
| 98 // a PasteboardRef, which isn't bridged with NSPasteboard. Ugh. | 98 // a PasteboardRef, which isn't bridged with NSPasteboard. Ugh. |
| 99 | 99 |
| 100 PasteboardRef pb_ref = NULL; | 100 PasteboardRef pb_ref = NULL; |
| 101 OSStatus status = PasteboardCreate(base::mac::NSToCFCast([pboard name]), | 101 OSStatus status = PasteboardCreate(base::mac::NSToCFCast([pboard name]), |
| 102 &pb_ref); | 102 &pb_ref); |
| 103 if (status != noErr || !pb_ref) { | 103 if (status != noErr || !pb_ref) { |
| 104 OSSTATUS_DCHECK(false, status) << "Error finding Carbon pasteboard"; | 104 OSSTATUS_DCHECK(false, status) << "Error finding Carbon pasteboard"; |
| 105 return nil; | 105 return nil; |
| 106 } | 106 } |
| 107 base::mac::ScopedCFTypeRef<PasteboardRef> pb_ref_scoper(pb_ref); | 107 base::ScopedCFTypeRef<PasteboardRef> pb_ref_scoper(pb_ref); |
| 108 PasteboardSynchronize(pb_ref); | 108 PasteboardSynchronize(pb_ref); |
| 109 | 109 |
| 110 CFURLRef drop_url = NULL; | 110 CFURLRef drop_url = NULL; |
| 111 status = PasteboardCopyPasteLocation(pb_ref, &drop_url); | 111 status = PasteboardCopyPasteLocation(pb_ref, &drop_url); |
| 112 if (status != noErr || !drop_url) { | 112 if (status != noErr || !drop_url) { |
| 113 OSSTATUS_DCHECK(false, status) << "Error finding drop location"; | 113 OSSTATUS_DCHECK(false, status) << "Error finding drop location"; |
| 114 return nil; | 114 return nil; |
| 115 } | 115 } |
| 116 base::mac::ScopedCFTypeRef<CFURLRef> drop_url_scoper(drop_url); | 116 base::ScopedCFTypeRef<CFURLRef> drop_url_scoper(drop_url); |
| 117 | 117 |
| 118 NSString* drop_path = [base::mac::CFToNSCast(drop_url) path]; | 118 NSString* drop_path = [base::mac::CFToNSCast(drop_url) path]; |
| 119 return drop_path; | 119 return drop_path; |
| 120 } | 120 } |
| 121 | 121 |
| 122 } // namespace | 122 } // namespace |
| 123 | 123 |
| 124 | 124 |
| 125 @interface WebDragSource(Private) | 125 @interface WebDragSource(Private) |
| 126 | 126 |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 net::GenerateFileName(downloadURL_, | 436 net::GenerateFileName(downloadURL_, |
| 437 std::string(), | 437 std::string(), |
| 438 std::string(), | 438 std::string(), |
| 439 fileName.value(), | 439 fileName.value(), |
| 440 mimeType, | 440 mimeType, |
| 441 defaultName); | 441 defaultName); |
| 442 } | 442 } |
| 443 } | 443 } |
| 444 | 444 |
| 445 if (!mimeType.empty()) { | 445 if (!mimeType.empty()) { |
| 446 base::mac::ScopedCFTypeRef<CFStringRef> mimeTypeCF( | 446 base::ScopedCFTypeRef<CFStringRef> mimeTypeCF( |
| 447 base::SysUTF8ToCFStringRef(mimeType)); | 447 base::SysUTF8ToCFStringRef(mimeType)); |
| 448 fileUTI_.reset(UTTypeCreatePreferredIdentifierForTag( | 448 fileUTI_.reset(UTTypeCreatePreferredIdentifierForTag( |
| 449 kUTTagClassMIMEType, mimeTypeCF.get(), NULL)); | 449 kUTTagClassMIMEType, mimeTypeCF.get(), NULL)); |
| 450 | 450 |
| 451 NSArray* types = | 451 NSArray* types = |
| 452 @[base::mac::CFToNSCast(kPasteboardTypeFileURLPromise), | 452 @[base::mac::CFToNSCast(kPasteboardTypeFileURLPromise), |
| 453 base::mac::CFToNSCast(kPasteboardTypeFilePromiseContent)]; | 453 base::mac::CFToNSCast(kPasteboardTypeFilePromiseContent)]; |
| 454 [pasteboard_ addTypes:types owner:contentsView_]; | 454 [pasteboard_ addTypes:types owner:contentsView_]; |
| 455 | 455 |
| 456 [pasteboard_ setPropertyList:@[base::mac::CFToNSCast(fileUTI_.get())] | 456 [pasteboard_ setPropertyList:@[base::mac::CFToNSCast(fileUTI_.get())] |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 - (NSImage*)dragImage { | 499 - (NSImage*)dragImage { |
| 500 if (dragImage_) | 500 if (dragImage_) |
| 501 return dragImage_; | 501 return dragImage_; |
| 502 | 502 |
| 503 // Default to returning a generic image. | 503 // Default to returning a generic image. |
| 504 return content::GetContentClient()->GetNativeImageNamed( | 504 return content::GetContentClient()->GetNativeImageNamed( |
| 505 IDR_DEFAULT_FAVICON).ToNSImage(); | 505 IDR_DEFAULT_FAVICON).ToNSImage(); |
| 506 } | 506 } |
| 507 | 507 |
| 508 @end // @implementation WebDragSource (Private) | 508 @end // @implementation WebDragSource (Private) |
| OLD | NEW |