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