| OLD | NEW |
| 1 /* ***** BEGIN LICENSE BLOCK ***** | 1 /* ***** BEGIN LICENSE BLOCK ***** |
| 2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 | 2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
| 3 * | 3 * |
| 4 * The contents of this file are subject to the Mozilla Public License Version | 4 * The contents of this file are subject to the Mozilla Public License Version |
| 5 * 1.1 (the "License"); you may not use this file except in compliance with | 5 * 1.1 (the "License"); you may not use this file except in compliance with |
| 6 * the License. You may obtain a copy of the License at | 6 * the License. You may obtain a copy of the License at |
| 7 * http://www.mozilla.org/MPL/ | 7 * http://www.mozilla.org/MPL/ |
| 8 * | 8 * |
| 9 * Software distributed under the License is distributed on an "AS IS" basis, | 9 * Software distributed under the License is distributed on an "AS IS" basis, |
| 10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | 10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 if ([types containsObject:NSStringPboardType]) { | 272 if ([types containsObject:NSStringPboardType]) { |
| 273 // Trim whitespace off the ends and newlines out of the middle so we don't r
eject otherwise-valid URLs; | 273 // Trim whitespace off the ends and newlines out of the middle so we don't r
eject otherwise-valid URLs; |
| 274 // we'll do another cleaning when we set the URLs and titles later, so this
is safe. | 274 // we'll do another cleaning when we set the URLs and titles later, so this
is safe. |
| 275 NSString* potentialURLString = [self cleanedStringWithPasteboardString:[self
stringForType:NSStringPboardType]]; | 275 NSString* potentialURLString = [self cleanedStringWithPasteboardString:[self
stringForType:NSStringPboardType]]; |
| 276 return [potentialURLString isValidURI]; | 276 return [potentialURLString isValidURI]; |
| 277 } | 277 } |
| 278 | 278 |
| 279 return NO; | 279 return NO; |
| 280 } | 280 } |
| 281 @end | 281 @end |
| 282 |
| 283 @implementation NSPasteboard(ChromiumHTMLUtils) |
| 284 |
| 285 // Convert the RTF to HTML via an NSAttributedString. |
| 286 - (NSString*)htmlFromRtf { |
| 287 if (![[self types] containsObject:NSRTFPboardType]) |
| 288 return @""; |
| 289 |
| 290 NSAttributedString* attributed = |
| 291 [[[NSAttributedString alloc] |
| 292 initWithRTF:[self dataForType:NSRTFPboardType] |
| 293 documentAttributes:nil] autorelease]; |
| 294 NSDictionary* attributeDict = |
| 295 [NSDictionary dictionaryWithObject:NSHTMLTextDocumentType |
| 296 forKey:NSDocumentTypeDocumentAttribute]; |
| 297 NSData* htmlData = |
| 298 [attributed dataFromRange:NSMakeRange(0, [attributed length]) |
| 299 documentAttributes:attributeDict |
| 300 error:nil]; |
| 301 // According to the docs, NSHTMLTextDocumentType is UTF8. |
| 302 return [[[NSString alloc] |
| 303 initWithData:htmlData encoding:NSUTF8StringEncoding] autorelease]; |
| 304 } |
| 305 |
| 306 @end |
| OLD | NEW |