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 #import <Carbon/Carbon.h> | 7 #import <Carbon/Carbon.h> |
8 | 8 |
9 #include "base/strings/sys_string_conversions.h" | 9 #include "base/strings/sys_string_conversions.h" |
10 #include "content/browser/renderer_host/render_view_host_impl.h" | 10 #include "content/browser/renderer_host/render_view_host_impl.h" |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 | 254 |
255 // Get URL if possible. To avoid exposing file system paths to web content, | 255 // Get URL if possible. To avoid exposing file system paths to web content, |
256 // filenames in the drag are not converted to file URLs. | 256 // filenames in the drag are not converted to file URLs. |
257 ui::PopulateURLAndTitleFromPasteboard(&data->url, | 257 ui::PopulateURLAndTitleFromPasteboard(&data->url, |
258 &data->url_title, | 258 &data->url_title, |
259 pboard, | 259 pboard, |
260 NO); | 260 NO); |
261 | 261 |
262 // Get plain text. | 262 // Get plain text. |
263 if ([types containsObject:NSStringPboardType]) { | 263 if ([types containsObject:NSStringPboardType]) { |
264 data->text = NullableString16( | 264 data->text = base::NullableString16( |
265 base::SysNSStringToUTF16([pboard stringForType:NSStringPboardType]), | 265 base::SysNSStringToUTF16([pboard stringForType:NSStringPboardType]), |
266 false); | 266 false); |
267 } | 267 } |
268 | 268 |
269 // Get HTML. If there's no HTML, try RTF. | 269 // Get HTML. If there's no HTML, try RTF. |
270 if ([types containsObject:NSHTMLPboardType]) { | 270 if ([types containsObject:NSHTMLPboardType]) { |
271 NSString* html = [pboard stringForType:NSHTMLPboardType]; | 271 NSString* html = [pboard stringForType:NSHTMLPboardType]; |
272 data->html = NullableString16(base::SysNSStringToUTF16(html), false); | 272 data->html = base::NullableString16(base::SysNSStringToUTF16(html), false); |
273 } else if ([types containsObject:ui::kChromeDragImageHTMLPboardType]) { | 273 } else if ([types containsObject:ui::kChromeDragImageHTMLPboardType]) { |
274 NSString* html = [pboard stringForType:ui::kChromeDragImageHTMLPboardType]; | 274 NSString* html = [pboard stringForType:ui::kChromeDragImageHTMLPboardType]; |
275 data->html = NullableString16(base::SysNSStringToUTF16(html), false); | 275 data->html = base::NullableString16(base::SysNSStringToUTF16(html), false); |
276 } else if ([types containsObject:NSRTFPboardType]) { | 276 } else if ([types containsObject:NSRTFPboardType]) { |
277 NSString* html = [pboard htmlFromRtf]; | 277 NSString* html = [pboard htmlFromRtf]; |
278 data->html = NullableString16(base::SysNSStringToUTF16(html), false); | 278 data->html = base::NullableString16(base::SysNSStringToUTF16(html), false); |
279 } | 279 } |
280 | 280 |
281 // Get files. | 281 // Get files. |
282 if ([types containsObject:NSFilenamesPboardType]) { | 282 if ([types containsObject:NSFilenamesPboardType]) { |
283 NSArray* files = [pboard propertyListForType:NSFilenamesPboardType]; | 283 NSArray* files = [pboard propertyListForType:NSFilenamesPboardType]; |
284 if ([files isKindOfClass:[NSArray class]] && [files count]) { | 284 if ([files isKindOfClass:[NSArray class]] && [files count]) { |
285 for (NSUInteger i = 0; i < [files count]; i++) { | 285 for (NSUInteger i = 0; i < [files count]; i++) { |
286 NSString* filename = [files objectAtIndex:i]; | 286 NSString* filename = [files objectAtIndex:i]; |
287 BOOL exists = [[NSFileManager defaultManager] | 287 BOOL exists = [[NSFileManager defaultManager] |
288 fileExistsAtPath:filename]; | 288 fileExistsAtPath:filename]; |
(...skipping 11 matching lines...) Expand all Loading... |
300 // Get custom MIME data. | 300 // Get custom MIME data. |
301 if ([types containsObject:ui::kWebCustomDataPboardType]) { | 301 if ([types containsObject:ui::kWebCustomDataPboardType]) { |
302 NSData* customData = [pboard dataForType:ui::kWebCustomDataPboardType]; | 302 NSData* customData = [pboard dataForType:ui::kWebCustomDataPboardType]; |
303 ui::ReadCustomDataIntoMap([customData bytes], | 303 ui::ReadCustomDataIntoMap([customData bytes], |
304 [customData length], | 304 [customData length], |
305 &data->custom_data); | 305 &data->custom_data); |
306 } | 306 } |
307 } | 307 } |
308 | 308 |
309 @end | 309 @end |
OLD | NEW |