Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(517)

Unified Diff: chrome/browser/cocoa/web_drag_source.mm

Issue 255035: Mac: *Correctly* fill file extension as drag source. (Closed)
Patch Set: Updated comments per Nico's review. Created 11 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/cocoa/web_drag_source.mm
diff --git a/chrome/browser/cocoa/web_drag_source.mm b/chrome/browser/cocoa/web_drag_source.mm
index a4266048359a8ceb3268ada4ab4f124bd0106bd0..f4461d4a95ab0bb74216c0a237622bbf31c5efbe 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];
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698