diff options
author | pinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-07 16:40:15 +0000 |
---|---|---|
committer | pinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-07 16:40:15 +0000 |
commit | ee43144e80ffecfa97e4226628483e66536eba48 (patch) | |
tree | 70fcbd7ba3ff79e649530001da38d599ca460641 /chrome/browser/cocoa | |
parent | 5b16a44b456ae36a6e22867c4cf3f6b8c556d4d4 (diff) | |
download | chromium_src-ee43144e80ffecfa97e4226628483e66536eba48.zip chromium_src-ee43144e80ffecfa97e4226628483e66536eba48.tar.gz chromium_src-ee43144e80ffecfa97e4226628483e66536eba48.tar.bz2 |
Fix up URIs of drags from the filesystem to allow them to be successfully dropped in the content area to load.
BUG=23517
TEST=dragging files, bookmarks, folders, text, etc to content area should behave correctly.
Review URL: http://codereview.chromium.org/267006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28260 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa')
-rw-r--r-- | chrome/browser/cocoa/web_drop_target.mm | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/chrome/browser/cocoa/web_drop_target.mm b/chrome/browser/cocoa/web_drop_target.mm index b797671..a7eaac6 100644 --- a/chrome/browser/cocoa/web_drop_target.mm +++ b/chrome/browser/cocoa/web_drop_target.mm @@ -176,11 +176,18 @@ using WebKit::WebDragOperationsMask; DCHECK([pboard containsURLData]); // The getURLs:andTitles: will already validate URIs so we don't need to - // again. The arrays it returns are both of NSString's. + // again. However, if the URI is a local file, it won't be prefixed with + // file://, which is what GURL expects. We can detect that case because the + // resulting URI will have no valid scheme, and we'll assume it's a local + // file. The arrays returned are both of NSString's. NSArray* urls = nil; NSArray* titles = nil; [pboard getURLs:&urls andTitles:&titles]; - data->url = GURL([[urls objectAtIndex:0] UTF8String]); + NSString* urlString = [urls objectAtIndex:0]; + NSURL* url = [NSURL URLWithString:urlString]; + if (![url scheme]) + urlString = [[NSURL fileURLWithPath:urlString] absoluteString]; + data->url = GURL([urlString UTF8String]); data->url_title = base::SysNSStringToUTF16([titles objectAtIndex:0]); } |