summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-29 14:44:38 +0000
committerviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-29 14:44:38 +0000
commit04fc0d936b61feced3a2b232a251923f014733bc (patch)
tree214fa133da3e765c1177d17c101409c3eeed75ea /chrome
parent49da58ecfe273d54754bc5c3a8841655b09955b9 (diff)
downloadchromium_src-04fc0d936b61feced3a2b232a251923f014733bc.zip
chromium_src-04fc0d936b61feced3a2b232a251923f014733bc.tar.gz
chromium_src-04fc0d936b61feced3a2b232a251923f014733bc.tar.bz2
Mac: Properly put the NSURLs on the pasteboard when dragging from web content.
Don't use the Mozilla code which (a) wasn't designed for lazy writes, and (b) is weird and kind of broken for file URLs. BUG=29911 TEST=Should be able to drag images (from a local web page) to Finder. Other drag-and-drop functionality (from web content) should continue to work as before. Review URL: http://codereview.chromium.org/1223005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42945 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/cocoa/web_drag_source.mm20
1 files changed, 14 insertions, 6 deletions
diff --git a/chrome/browser/cocoa/web_drag_source.mm b/chrome/browser/cocoa/web_drag_source.mm
index 174df6c..8f5efe7 100644
--- a/chrome/browser/cocoa/web_drag_source.mm
+++ b/chrome/browser/cocoa/web_drag_source.mm
@@ -31,6 +31,10 @@ using net::FileStream;
namespace {
+// An unofficial standard pasteboard title type to be provided alongside the
+// |NSURLPboardType|.
+NSString* const kNSURLTitlePboardType = @"public.url-name";
+
// Make a drag image from the drop data.
// TODO(viettrungluu): Move this somewhere more sensible.
NSImage* MakeDragImage(const WebDropData* drop_data) {
@@ -158,10 +162,13 @@ void PromiseWriterTask::Run() {
// URL.
} else if ([type isEqualToString:NSURLPboardType]) {
DCHECK(dropData_->url.is_valid());
- [pboard setURLs:[NSArray
- arrayWithObject:SysUTF8ToNSString(dropData_->url.spec())]
- withTitles:[NSArray arrayWithObject:
- SysUTF16ToNSString(dropData_->url_title)]];
+ NSURL* url = [NSURL URLWithString:SysUTF8ToNSString(dropData_->url.spec())];
+ [url writeToPasteboard:pboard];
+
+ // URL title.
+ } else if ([type isEqualToString:kNSURLTitlePboardType]) {
+ [pboard setString:SysUTF16ToNSString(dropData_->url_title)
+ forType:kNSURLTitlePboardType];
// File contents.
} else if ([type isEqualToString:NSFileContentsPboardType] ||
@@ -320,9 +327,10 @@ void PromiseWriterTask::Run() {
[pasteboard_ addTypes:[NSArray arrayWithObject:NSHTMLPboardType]
owner:contentsView_];
- // URL.
+ // URL (and title).
if (dropData_->url.is_valid())
- [pasteboard_ addTypes:[NSArray arrayWithObject:NSURLPboardType]
+ [pasteboard_ addTypes:[NSArray arrayWithObjects:NSURLPboardType,
+ kNSURLTitlePboardType, nil]
owner:contentsView_];
// File.