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_dest_mac.h" | 5 #import "content/browser/web_contents/web_drag_dest_mac.h" |
6 | 6 |
7 #include "base/sys_string_conversions.h" | 7 #include "base/sys_string_conversions.h" |
8 #include "content/browser/renderer_host/render_view_host_impl.h" | 8 #include "content/browser/renderer_host/render_view_host_impl.h" |
9 #include "content/browser/web_contents/web_contents_impl.h" | 9 #include "content/browser/web_contents/web_contents_impl.h" |
10 #include "content/public/browser/web_drag_dest_delegate.h" | 10 #include "content/public/browser/web_drag_dest_delegate.h" |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 NSString* html = [pboard htmlFromRtf]; | 230 NSString* html = [pboard htmlFromRtf]; |
231 data->text_html = base::SysNSStringToUTF16(html); | 231 data->text_html = base::SysNSStringToUTF16(html); |
232 } | 232 } |
233 | 233 |
234 // Get files. | 234 // Get files. |
235 if ([types containsObject:NSFilenamesPboardType]) { | 235 if ([types containsObject:NSFilenamesPboardType]) { |
236 NSArray* files = [pboard propertyListForType:NSFilenamesPboardType]; | 236 NSArray* files = [pboard propertyListForType:NSFilenamesPboardType]; |
237 if ([files isKindOfClass:[NSArray class]] && [files count]) { | 237 if ([files isKindOfClass:[NSArray class]] && [files count]) { |
238 for (NSUInteger i = 0; i < [files count]; i++) { | 238 for (NSUInteger i = 0; i < [files count]; i++) { |
239 NSString* filename = [files objectAtIndex:i]; | 239 NSString* filename = [files objectAtIndex:i]; |
240 BOOL isDir = NO; | 240 BOOL exists = [[NSFileManager defaultManager] |
241 BOOL exists = [[NSFileManager defaultManager] fileExistsAtPath:filename | 241 fileExistsAtPath:filename]; |
242 isDirectory:&isDir]; | 242 if (exists) { |
243 if (exists && !isDir) { | |
244 data->filenames.push_back( | 243 data->filenames.push_back( |
245 WebDropData::FileInfo( | 244 WebDropData::FileInfo( |
246 base::SysNSStringToUTF16(filename), string16())); | 245 base::SysNSStringToUTF16(filename), string16())); |
247 } | 246 } |
248 } | 247 } |
249 } | 248 } |
250 } | 249 } |
251 | 250 |
252 // TODO(pinkerton): Get file contents. http://crbug.com/34661 | 251 // TODO(pinkerton): Get file contents. http://crbug.com/34661 |
253 | 252 |
254 // Get custom MIME data. | 253 // Get custom MIME data. |
255 if ([types containsObject:ui::kWebCustomDataPboardType]) { | 254 if ([types containsObject:ui::kWebCustomDataPboardType]) { |
256 NSData* customData = [pboard dataForType:ui::kWebCustomDataPboardType]; | 255 NSData* customData = [pboard dataForType:ui::kWebCustomDataPboardType]; |
257 ui::ReadCustomDataIntoMap([customData bytes], | 256 ui::ReadCustomDataIntoMap([customData bytes], |
258 [customData length], | 257 [customData length], |
259 &data->custom_data); | 258 &data->custom_data); |
260 } | 259 } |
261 } | 260 } |
262 | 261 |
263 @end | 262 @end |
OLD | NEW |