OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_drop_target.h" | 5 #import "chrome/browser/cocoa/web_drop_target.h" |
6 | 6 |
7 #include "base/sys_string_conversions.h" | 7 #include "base/sys_string_conversions.h" |
8 #include "chrome/browser/bookmarks/bookmark_drag_data.h" | 8 #include "chrome/browser/bookmarks/bookmark_drag_data.h" |
9 #include "chrome/browser/bookmarks/bookmark_pasteboard_helper_mac.h" | 9 #include "chrome/browser/bookmarks/bookmark_pasteboard_helper_mac.h" |
10 #include "chrome/browser/renderer_host/render_view_host.h" | 10 #include "chrome/browser/renderer_host/render_view_host.h" |
11 #include "chrome/browser/tab_contents/tab_contents.h" | 11 #include "chrome/browser/tab_contents/tab_contents.h" |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 andTitle:&data->url_title | 246 andTitle:&data->url_title |
247 fromPasteboard:pboard | 247 fromPasteboard:pboard |
248 convertingFilenames:NO]; | 248 convertingFilenames:NO]; |
249 | 249 |
250 // Get plain text. | 250 // Get plain text. |
251 if ([types containsObject:NSStringPboardType]) { | 251 if ([types containsObject:NSStringPboardType]) { |
252 data->plain_text = | 252 data->plain_text = |
253 base::SysNSStringToUTF16([pboard stringForType:NSStringPboardType]); | 253 base::SysNSStringToUTF16([pboard stringForType:NSStringPboardType]); |
254 } | 254 } |
255 | 255 |
256 // Get HTML. | 256 // Get HTML. If there's no HTML, try RTF. |
257 if ([types containsObject:NSHTMLPboardType]) { | 257 if ([types containsObject:NSHTMLPboardType]) { |
258 data->text_html = | 258 data->text_html = |
259 base::SysNSStringToUTF16([pboard stringForType:NSHTMLPboardType]); | 259 base::SysNSStringToUTF16([pboard stringForType:NSHTMLPboardType]); |
| 260 } else if ([types containsObject:NSRTFPboardType]) { |
| 261 NSString* html = [pboard htmlFromRtf]; |
| 262 data->text_html = base::SysNSStringToUTF16(html); |
260 } | 263 } |
261 | 264 |
262 // Get files. | 265 // Get files. |
263 if ([types containsObject:NSFilenamesPboardType]) { | 266 if ([types containsObject:NSFilenamesPboardType]) { |
264 NSArray* files = [pboard propertyListForType:NSFilenamesPboardType]; | 267 NSArray* files = [pboard propertyListForType:NSFilenamesPboardType]; |
265 if ([files isKindOfClass:[NSArray class]] && [files count]) { | 268 if ([files isKindOfClass:[NSArray class]] && [files count]) { |
266 for (NSUInteger i = 0; i < [files count]; i++) { | 269 for (NSUInteger i = 0; i < [files count]; i++) { |
267 NSString* filename = [files objectAtIndex:i]; | 270 NSString* filename = [files objectAtIndex:i]; |
268 BOOL isDir = NO; | 271 BOOL isDir = NO; |
269 BOOL exists = [[NSFileManager defaultManager] fileExistsAtPath:filename | 272 BOOL exists = [[NSFileManager defaultManager] fileExistsAtPath:filename |
270 isDirectory:&isDir]; | 273 isDirectory:&isDir]; |
271 if (exists && !isDir) | 274 if (exists && !isDir) |
272 data->filenames.push_back(base::SysNSStringToUTF16(filename)); | 275 data->filenames.push_back(base::SysNSStringToUTF16(filename)); |
273 } | 276 } |
274 } | 277 } |
275 } | 278 } |
276 | 279 |
277 // TODO(pinkerton): Get file contents. http://crbug.com/34661 | 280 // TODO(pinkerton): Get file contents. http://crbug.com/34661 |
278 } | 281 } |
279 | 282 |
280 @end | 283 @end |
OLD | NEW |