| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "chrome/browser/cocoa/web_drag_source.h" | 5 #import "chrome/browser/cocoa/web_drag_source.h" |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/nsimage_cache_mac.h" | 8 #include "base/nsimage_cache_mac.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/sys_string_conversions.h" | 10 #include "base/sys_string_conversions.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 FilePath GetFileNameFromDragData( | 45 FilePath GetFileNameFromDragData( |
| 46 const WebDropData& drop_data, unsigned seq) { | 46 const WebDropData& drop_data, unsigned seq) { |
| 47 // Images without ALT text will only have a file extension so we need to | 47 // Images without ALT text will only have a file extension so we need to |
| 48 // synthesize one from the provided extension and URL. | 48 // synthesize one from the provided extension and URL. |
| 49 FilePath file_name([SysUTF16ToNSString(drop_data.file_description_filename) | 49 FilePath file_name([SysUTF16ToNSString(drop_data.file_description_filename) |
| 50 fileSystemRepresentation]); | 50 fileSystemRepresentation]); |
| 51 file_name = file_name.BaseName().RemoveExtension(); | 51 file_name = file_name.BaseName().RemoveExtension(); |
| 52 | 52 |
| 53 if (file_name.empty()) { | 53 if (file_name.empty()) { |
| 54 // Retrieve the name from the URL. | 54 // Retrieve the name from the URL. |
| 55 file_name = FilePath::FromWStringHack( | 55 file_name = net::GetSuggestedFilename(drop_data.url, "", "", ""); |
| 56 net::GetSuggestedFilename(drop_data.url, "", "", L"")); | |
| 57 } | 56 } |
| 58 | 57 |
| 59 file_name = file_name.ReplaceExtension([SysUTF16ToNSString( | 58 file_name = file_name.ReplaceExtension([SysUTF16ToNSString( |
| 60 drop_data.file_extension) fileSystemRepresentation]); | 59 drop_data.file_extension) fileSystemRepresentation]); |
| 61 | 60 |
| 62 if (seq > 0) { | 61 if (seq > 0) { |
| 63 file_name = | 62 file_name = |
| 64 file_name.InsertBeforeExtension(std::string("-")+UintToString(seq)); | 63 file_name.InsertBeforeExtension(std::string("-")+UintToString(seq)); |
| 65 } | 64 } |
| 66 | 65 |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 if (!dropData_->plain_text.empty()) | 356 if (!dropData_->plain_text.empty()) |
| 358 [pasteboard_ addTypes:[NSArray arrayWithObject:NSStringPboardType] | 357 [pasteboard_ addTypes:[NSArray arrayWithObject:NSStringPboardType] |
| 359 owner:contentsView_]; | 358 owner:contentsView_]; |
| 360 } | 359 } |
| 361 | 360 |
| 362 - (NSImage*)dragImage { | 361 - (NSImage*)dragImage { |
| 363 return MakeDragImage(dropData_.get()); | 362 return MakeDragImage(dropData_.get()); |
| 364 } | 363 } |
| 365 | 364 |
| 366 @end // @implementation WebDragSource (Private) | 365 @end // @implementation WebDragSource (Private) |
| OLD | NEW |