summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cocoa/web_drag_source.mm
diff options
context:
space:
mode:
authorviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-01 05:01:55 +0000
committerviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-01 05:01:55 +0000
commit00c4079ca3b6753db530bc8c5522793f25aa6619 (patch)
tree61c7d9a370f710d113718abd71944f59b038440f /chrome/browser/cocoa/web_drag_source.mm
parent2318345bb6391d6db9b3113be49e5a14ac9cb5b0 (diff)
downloadchromium_src-00c4079ca3b6753db530bc8c5522793f25aa6619.zip
chromium_src-00c4079ca3b6753db530bc8c5522793f25aa6619.tar.gz
chromium_src-00c4079ca3b6753db530bc8c5522793f25aa6619.tar.bz2
Mac: *Correctly* fill file extension as drag source.
(We have to strip the '.' from the file extension.) BUG=23431 TEST=Make sure images can still be dragged to, e.g., the desktop; make sure images can be dragged to Acorn <http://www.flyingmeat.com/acorn/>. Review URL: http://codereview.chromium.org/255035 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27704 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/web_drag_source.mm')
-rw-r--r--chrome/browser/cocoa/web_drag_source.mm27
1 files changed, 15 insertions, 12 deletions
diff --git a/chrome/browser/cocoa/web_drag_source.mm b/chrome/browser/cocoa/web_drag_source.mm
index a426604..f4461d4 100644
--- a/chrome/browser/cocoa/web_drag_source.mm
+++ b/chrome/browser/cocoa/web_drag_source.mm
@@ -29,9 +29,10 @@ using net::FileStream;
namespace {
// Make a drag image from the drop data.
-// TODO(viettrungluu@gmail.com): Move this somewhere more sensible.
+// TODO(viettrungluu): Move this somewhere more sensible.
NSImage* MakeDragImage(const WebDropData* drop_data) {
- // TODO(viettrungluu@gmail.com): Just a stub for now. Make it do something.
+ // TODO(viettrungluu): Just a stub for now. Make it do something (see, e.g.,
+ // WebKit/WebKit/mac/Misc/WebNSViewExtras.m: |-_web_DragImageForElement:...|).
// Default to returning a generic image.
return nsimage_cache::ImageNamed(@"nav.pdf");
@@ -39,7 +40,7 @@ NSImage* MakeDragImage(const WebDropData* drop_data) {
// Returns a filename appropriate for the drop data (of form "FILENAME-seq.EXT"
// if seq > 0).
-// TODO(viettrungluu@gmail.com): Refactor to make it common across platforms,
+// TODO(viettrungluu): Refactor to make it common across platforms,
// and move it somewhere sensible.
FilePath GetFileNameFromDragData(
const WebDropData& drop_data, unsigned seq) {
@@ -171,7 +172,7 @@ void PromiseWriterTask::Run() {
} else if ([type isEqualToString:NSFileContentsPboardType] ||
[type isEqualToString:NSCreateFileContentsPboardType(
SysUTF16ToNSString(dropData_->file_extension))]) {
- // TODO(viettrungluu@gmail.com): find something which is known to accept
+ // TODO(viettrungluu: find something which is known to accept
// NSFileContentsPboardType to check that this actually works!
scoped_nsobject<NSFileWrapper> file_wrapper(
[[NSFileWrapper alloc] initRegularFileWithContents:[NSData
@@ -183,10 +184,9 @@ void PromiseWriterTask::Run() {
// TIFF.
} else if ([type isEqualToString:NSTIFFPboardType]) {
- // FIXME(viettrungluu@gmail.com): This is a bit odd since we rely on Cocoa
- // to render our image into a TIFF. This is also suboptimal since this is
- // all done synchronously. I'm not sure there's much we can easily do about
- // it.
+ // TODO(viettrungluu): This is a bit odd since we rely on Cocoa to render
+ // our image into a TIFF. This is also suboptimal since this is all done
+ // synchronously. I'm not sure there's much we can easily do about it.
scoped_nsobject<NSImage> image(
[[NSImage alloc] initWithData:[NSData
dataWithBytes:dropData_->file_contents.data()
@@ -333,20 +333,23 @@ void PromiseWriterTask::Run() {
// File.
if (!dropData_->file_contents.empty()) {
- NSString* file_ext = SysUTF16ToNSString(dropData_->file_extension);
+ // |dropData_->file_extension| comes with the '.', which we must strip.
+ NSString* fileExtension =
+ (dropData_->file_extension.length() > 0) ?
+ SysUTF16ToNSString(dropData_->file_extension.substr(1)) : @"";
// File contents (with and without specific type), file (HFS) promise, TIFF.
- // TODO(viettrungluu@gmail.com): others?
+ // TODO(viettrungluu): others?
[pasteboard_ addTypes:[NSArray arrayWithObjects:
NSFileContentsPboardType,
- NSCreateFileContentsPboardType(file_ext),
+ NSCreateFileContentsPboardType(fileExtension),
NSFilesPromisePboardType,
NSTIFFPboardType,
nil]
owner:contentsView_];
// For the file promise, we need to specify the extension.
- [pasteboard_ setPropertyList:[NSArray arrayWithObject:file_ext]
+ [pasteboard_ setPropertyList:[NSArray arrayWithObject:fileExtension]
forType:NSFilesPromisePboardType];
}