OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/web_contents/web_drag_source_mac.h" | 5 #import "content/browser/web_contents/web_drag_source_mac.h" |
6 | 6 |
7 #include <sys/param.h> | 7 #include <sys/param.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/files/file.h" | 10 #include "base/files/file.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 // Returns a filename appropriate for the drop data | 62 // Returns a filename appropriate for the drop data |
63 // TODO(viettrungluu): Refactor to make it common across platforms, | 63 // TODO(viettrungluu): Refactor to make it common across platforms, |
64 // and move it somewhere sensible. | 64 // and move it somewhere sensible. |
65 base::FilePath GetFileNameFromDragData(const DropData& drop_data) { | 65 base::FilePath GetFileNameFromDragData(const DropData& drop_data) { |
66 base::FilePath file_name( | 66 base::FilePath file_name( |
67 FilePathFromFilename(drop_data.file_description_filename)); | 67 FilePathFromFilename(drop_data.file_description_filename)); |
68 | 68 |
69 // Images without ALT text will only have a file extension so we need to | 69 // Images without ALT text will only have a file extension so we need to |
70 // synthesize one from the provided extension and URL. | 70 // synthesize one from the provided extension and URL. |
71 if (file_name.empty()) { | 71 if (file_name.empty()) { |
72 // Retrieve the name from the URL. | 72 file_name = |
73 base::string16 suggested_filename = | 73 net::GenerateFileName(drop_data.url, std::string(), std::string(), |
74 net::GetSuggestedFilename(drop_data.url, "", "", "", "", ""); | 74 std::string(), std::string(), std::string()); |
75 const std::string extension = file_name.Extension(); | |
76 file_name = FilePathFromFilename(suggested_filename); | |
77 file_name = file_name.ReplaceExtension(extension); | |
78 } | 75 } |
79 | 76 |
80 return file_name; | 77 return file_name; |
81 } | 78 } |
82 | 79 |
83 // This helper's sole task is to write out data for a promised file; the caller | 80 // This helper's sole task is to write out data for a promised file; the caller |
84 // is responsible for opening the file. It takes the drop data and an open file | 81 // is responsible for opening the file. It takes the drop data and an open file |
85 // stream. | 82 // stream. |
86 void PromiseWriterHelper(const DropData& drop_data, | 83 void PromiseWriterHelper(const DropData& drop_data, |
87 base::File file) { | 84 base::File file) { |
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 - (NSImage*)dragImage { | 454 - (NSImage*)dragImage { |
458 if (dragImage_) | 455 if (dragImage_) |
459 return dragImage_; | 456 return dragImage_; |
460 | 457 |
461 // Default to returning a generic image. | 458 // Default to returning a generic image. |
462 return content::GetContentClient()->GetNativeImageNamed( | 459 return content::GetContentClient()->GetNativeImageNamed( |
463 IDR_DEFAULT_FAVICON).ToNSImage(); | 460 IDR_DEFAULT_FAVICON).ToNSImage(); |
464 } | 461 } |
465 | 462 |
466 @end // @implementation WebDragSource (Private) | 463 @end // @implementation WebDragSource (Private) |
OLD | NEW |